check value in textbox/combo box (1 Viewer)

Trilback

Registered User.
Local time
Today, 01:33
Joined
Nov 29, 2013
Messages
88
I need to check the value in a textbox/Combo box to see if it's in a specific field in a table. I was thinking I could use the dlookup command on my after update event. Info is below.

Table Name: Agent List
Field in Table: AGENT ID

textbox/Combobox on forum: Agent_ID
 

Ranman256

Well-known member
Local time
Today, 01:33
Joined
Apr 9, 2015
Messages
4,338
You can just run a query to open the item in the textbox.
Or
You can fill another label box with a message using Dlookup...
LblMsg.caption = dlookup("[AgentName]","AgentTbl","[AgentID]=" & me.cboBox )
 

Trilback

Registered User.
Local time
Today, 01:33
Joined
Nov 29, 2013
Messages
88
You can just run a query to open the item in the textbox.
Or
You can fill another label box with a message using Dlookup...
LblMsg.caption = dlookup("[AgentName]","AgentTbl","[AgentID]=" & me.cboBox )

trying to think how to make an if statement so something like this. I know it's not correct but just need a little help.

Code:
If Agent_ID =  dlookup("AGENT ID", "Agent List" then

MsgBox "I am an agent"

Else

MsgBox "I could not find that Agent ID." & vbNewLine & "Please make sure you typed the Agent ID correct"

End If
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:33
Joined
Feb 19, 2013
Messages
16,751
try

Code:
If dcount("[AGENT ID]", "[Agent List]","[AGENT ID]=" & Agent_ID)<>0 then
......
Note: having spaces in names is generally a bad idea
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:33
Joined
Feb 19, 2013
Messages
16,751
for the benefit of other readers who may have the same problem - please can you post your solution
 

Users who are viewing this thread

Top Bottom