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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup to search for matching criteria when record exists

Status
Not open for further replies.

rhinomac

Programmer
Jan 24, 2003
34
US
I am trying to verify that a field (assignment)in a record matches an existing criteria (BREAK-FIX) in an if statement.
I am using a dlookup to take the existing record that is not the primary key and if the criteria matches then continue with the statement and open a form if not then msg box.
heres a sample of the code:

If not IsNull (DLookup "[assignment]", "dbo_problemm1", "[assignment] = '" + "BREAK-FIX" + "'")) Then

DoCmd.OpenForm "hotswapevent", , , "[number] = '" & Me![number] & "'"

Else

MsgBox "Problem Ticket is not a Break fix, Please enter another Ticket.", 48
Me!number.SetFocus


End If
 
Also if anybody knows any good references for dlookup function that i could use please let me know...
 
Hallo,

The access help facility describes DLookup pretty well, IMHO.

Making loads of assumtions, is this what you want to do?

Code:
dim strNumber as String

strNumber=Nz(DLookup("number","dbo_problemm1","assignment='BREAK-FIX'"),"")
if strNumber <> &quot;&quot; then
  DoCmd.OpenForm &quot;hotswapevent&quot;, , , &quot;[number] = '&quot; & strNumber & &quot;'&quot;
Else
  MsgBox &quot;Problem Ticket is not a Break fix, Please enter another Ticket.&quot;, 48
  Me!number.SetFocus
end if

If that's not what you wanted to do then can you give some more info?

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top