New a 'find record' code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 3 different fields (account name, telephone number, &
account number). I would like to create a code so that when data is entered
into either of the fields (like when an acct# is entered) and the search
button below is clicked, the account number with the corresponding data comes
up. Can anyone help? Please bare with me, i'm a newbie :)
 
Thanks for the info. The code worked perfectly. I hope i'm not getting too
greedy but I would like to take the code just a little bit further. Is there
a way to enter in an expression that will run a macro I created for 'unfound
entries'? The DoCmd.OpenQuery commands work perfectly for the values that
are located but I would like to run that macro when the value is not found.
Thanks
-Cheyenne

hi,
you will need to create 3 different select queries. put
all 3 data fields in each query and name then something
like qryByAcctNum, qryByAcctNam , qryByTelNum.
then in each query, in the appropreate column, in the
criteria pane put this
[Forms]![yourformname]![AcctNumberTextBoxName]
[Forms]![yourformname]![AcctNameTextBoxName]
[Forms]![yourformname]![TeleNumberTextBoxName]
be sure to put only one criteria in the appropreate
query.
just be sure to use your form name and the text box names
in your form.
once you have the 3 queries, put a search button on the
form.
put this code behind the button
private sub cmdfind_click()
on error resume next
if not isnull(me.AcctNumberTextBoxName) then
docmd.openquery "qryByAcctNum", acviewnormal
else
if not isnull(me.AcctNameTxtBoxName then
Docmd.openquery "qryByAcctName", Acviewnormal
else
if Not isnull(me.TeleNumberTextBoxName) then
docmd.openquery "qryByTeleNum", acviewnormal
end if
end if
end if
end sub
-----Original Message-----
I have a form with 3 different fields (account name, telephone number, &
account number). I would like to create a code so that when data is entered
into either of the fields (like when an acct# is entered) and the search
button below is clicked, the account number with the corresponding data comes
up. Can anyone help? Please bare with me, i'm a newbie :)
.
 
Back
Top