Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 29, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: CheckBox not checked
Renee Bender
Posts: 74
 
CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 1:56 PM
I know there is probably a simple answer to my question. I am trying to loop through a record set and have a check box display as checked depending on the value in my record set. Can someone please look at my code and see what I am doing wrong. I know this is pretty knew to me and I am just not seeing what is wrong.
Thanks,
Renee

do while objrs.eof = false
if objRS.Fields.Item("ContactType").Value = "B" then
ChkBxBusiness.Checked = True
End if

if objRS.Fields.Item("ContactType").Value = "S" then
ChkBxScheduling.Checked = true
End if

if objRS.Fields.Item("ContactType").Value = "P" then
ChkBxMailing.Checked = true
End if

if objRS.Fields.Item("ContactType").Value = "L" then
ChkBxLegal.Checked = true
End if

if objRS.Fields.Item("ContactType").Value = "T" then
ChkBxTechnical.Checked = true
end if

objRS.movenext
loop
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 2:43 PM
What are the symptoms that you are observing? I it that none of the checkboxes are getting checked?
SalesLogix uses "T" and "F" as the Textvalue for checkboxes, so you might want to try setting the Text value instead.

That being said, have you checked if your recordset contains any of these values? Also, keep in mind that the comparisson is case sensitive, so "b" won't be equal to "B".

Additionally, in general terms, you should at least use If/Else If, but probably should try to use a Case statement:
I would try something as follows

Do While Not objRS.EOF
Dim val
'I Add & "" to force the value to be converted to a blank string instead of a NULL, which may be what's making your code break. I the first item on your recordset has a null, it would've failed.
val = UCase(objRS("ContactType").Value & "")

Select Case
Case "B":
ChkBxBusiness.Checked = True
Case "S":
ChkBxScheduling.Checked = True
...
End Select
Loop
[Reply][Quote]
Renee Bender
Posts: 74
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 3:13 PM
Sorry about that. I am currently on version 7.5.1. What is happening is that I know that my recordset has data because I put a message box in that displays the ContactType each time it loops through. Then when the screen displays, the checkboxes are still blank.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 3:15 PM
Try setting the Text value:

ChkBox.Text = "T"
[Reply][Quote]
Renee Bender
Posts: 74
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 3:24 PM
No change. I'm sure there must be something that I am missing. I just don't see it.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 3:36 PM
Do you have any other code associated with these controls?
Do you know if the code is getting to the If statements (e.g. adding a message box inside the If that sets a box)
Also, have you made sure that there are no empty spaces on that db field. I would say, add a Trim around the field:

val = Trim(UCase(objRS("FIELD").Value & ""))
' Test to make sure there are no special hidden characters:
msgbox "X" & val & "X"
[Reply][Quote]
Renee Bender
Posts: 74
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 3:38 PM
Found my problem! I knew it was going to be something simple. The field in the table is a length of 30, which I didn't realize until now. I added a trim to the line of code and it works great now!
Thanks for all your help!!!!
Renee
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 09 7:41 PM
Question:

Was the field defined as char(30)?
I know it may seem as a small tidbit, but you may want to consider it defining it as varchar(30).
It saves you a few bytes per record. They may not be that important to begin with, but on the long run it may.

If the field is defined as char(30), then SQL will return the value padded with blanks. If the field is defined as varchar(30), SQL would only return the value padded with blanks if you padded it when you wrote it.
[Reply][Quote]
Renee Bender
Posts: 74
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 09 7:09 AM
It is defined as char(30). Not sure why the person that created the table did it that way since we only store a 1 letter value in that field. I am fairly new at this and just want to make sure that if I change it to varchar, it won't cause a problem for any of the programming that is already in place will it?
Thanks,
Renee
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 09 7:22 AM
It shouldn't as long as there isn't code trying to insert more than 1 character.

Question: Do you have SLX Remotes? Was this table created inside SLX?
As far as I recall, any fields created within the DB manager would've been defined as varchar, so it is likely this table was created directly on SQL, then added onto SLX.


If you are using remotes, you may have to think about your strategy to make this change. If you want the change to synchronize you would have to do it within SLX.
[Reply][Quote]
Renee Bender
Posts: 74
 
Re: CheckBox not checkedYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 09 7:28 AM
I'm not sure how the table was created. It was done by someone who is no longer here and before I became involved with Saleslogix.

We do not have remote users, so synchronizing would not be a problem.

Thanks for all your help!
Renee
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/29/2024 6:28:08 PM