TextBox condition not working

IMyself

Registered User.
Local time
Today, 20:32
Joined
Oct 15, 2019
Messages
30
Hi there...
I got a situation and something is wrong. I dont know the problem is with the code or what.
there is a text box which is for typing id in it, and a button to go to the record of that id, and I wanted to input a condition like this:

sub CmdGotoID_Click ()

If TxtBoxID.Value = Me.ID then
msgbox "You are in this page already!"
End If
End Sub

but nothing happens when the condition is true in the form and I press the button.
 
no message displayed?
 
No, Nothing Happens at all
 
maybe wrong textbox name...
 
to be made sure, I did this Also:


sub CmdGotoID_Click ()
msgbox TxtBoxID.Value & Me.ID
End Sub

and in page have id 2, I did type 2 in text box and clicked the button, and a message popped showing "22" !
 
sub CmdGotoID_Click ()

If Val(TxtBoxID.Value & "") = Val(Me.ID & "") then
msgbox "You are in this page already!"
End If
End Sub
 
Absolutely Right !! Thanks Dear
So why that didnt work ?? and what would the "" will do ??
 
Absolutely Right !! Thanks Dear
So why that didnt work ?? and what would the "" will do ??
Hi. Is your ID field a Text field? If so, you could try this as well:
Code:
If Me.ID = '" & Me.TxtBoxID & "'" Then
 

Users who are viewing this thread

Back
Top Bottom