Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning value to a checkbox?

Status
Not open for further replies.

Visiting

IS-IT--Management
Nov 26, 2002
21
0
0
US
How do I give a checkbox a checked image? I tried using code like "If (Condition) Then Me!Checkbx = False End If", but I get an error message about not being able to assign a value.

Thanks for any help.
 
You can make a checkbox blank by making it NULL... a messy way would then be to Me!Checkbx = Not Null I'm sure there's a nicer way to do it, tho. Jennifer Sigman
Code-borrower extraordinaire
"They call us public servants for a reason..."
 
Thanks so much, it works, that's what matters!
 
Ack! I'm getting a run-time error now that says: "Can't assign a value to the object"?
 
Hmmm... might want to post the whole code here, it'll make it easier to debug. Jennifer Sigman
Code-borrower extraordinaire
"They call us public servants for a reason..."
 
Here you go, thanks!

Private Sub TextEntry_AfterUpdate()
Dim M
Dim last As String

last = "LastName = '" & TextEntry & "'"

M = DLookup("CheckField", "TABLE", last)

If M = Null Then
Me!CheckM1 = Null

Else
Check = Not Null
End If

End Sub
 
Sorry, in the Else clause the statement should be Me!CheckM1 = Not Null
 
On your Else... should be the same as the first one, I think... in other words:

If M = Null Then
Me!CheckM1 = Null
Else
Me!CheckM1 = Not Null Jennifer Sigman
Code-borrower extraordinaire
"They call us public servants for a reason..."
 
Is there a different way that I should be assigning the checked display to CheckM1?
 
Try This.

If IsNull(M) Then
Me!CheckM1 = 0
Else
Me!CheckM1 = -1
End If
 
Shouldn't it be "Me.Check" instead of "Me!Check"? I don't know...
Onwards,

Q-
 
i think it should be me. not me!

also, use 0 for false, and -1 for true (checked)

also, make sure that the field is able to be changed by hand... if it not able to be changed by hand, make it able to... then test your code... i have a feeling your problem is with the field being protected in some way...

--junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
A couple things . .


If IsNull(M) Then
Me.CheckM1 = True
Else
Me.CheckM1 = False
End If

Also, I'm not sure if M will evaluate as null even if the Dlookup fails . . maybe something like:

If IsNull(DLookup . .etc)

- - - -

Bry
 
Thanks a million to everyone that replied! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top