Search button to populate information

  • Thread starter yomi m via AccessMonster.com
  • Start date
Y

yomi m via AccessMonster.com

Okay i seriously need some quick help. I have an unbound text box
(txtContact) that phone number are entered into. When i hit the command
button (cmdSearch) i want to open a new form (Search Numbers), and have the
fields name and organization combo boxes to reflect the data based on
thephone number. i have a query that is based off a main table. i want the
search command button to read the query, find the phone number, and input a
name and org into the designated fields assigned to the number. I have been
trying to figure this out for weeks, what will the code be behind the search
button?
 
G

Guest

hi,
you could use DLookup.

Me.txtname = DLookup("[name]", "yourtabel", "[PhoneNum] = '" &
[Forms]![yourfirstform]![txtphonenum] & "'")

note: this wrapped. should be one line

I've used this technique many time to populate a form. you would need a
DLookup of each text box you want to populate.

regards
FSt1
 
Y

yomi m via AccessMonster.com

okay where do i put the d lookup statement. I want the form to look up
(Contact Number) on a query called (Customer Info), and send (Contact Name)
and (Organization) found into the (cmbName) and (cmb Organization) text boxes.

hi,
you could use DLookup.

Me.txtname = DLookup("[name]", "yourtabel", "[PhoneNum] = '" &
[Forms]![yourfirstform]![txtphonenum] & "'")

note: this wrapped. should be one line

I've used this technique many time to populate a form. you would need a
DLookup of each text box you want to populate.

regards
FSt1
Okay i seriously need some quick help. I have an unbound text box
(txtContact) that phone number are entered into. When i hit the command
[quoted text clipped - 5 lines]
trying to figure this out for weeks, what will the code be behind the search
button?
 
G

Guest

hi,
if you use DLookup, the form will not lookup anything in the query. DLookup
goes streight to the table to get the info. that is why you need a DLookup
statement for each data bit you want.
Form what you just posted, you will need 2 DLookup Statements. 1 for contact
Name and 1 for organization.

Me.cmbname = DLookup("[Contact name]", "yourTable", "[contact] = '" &
[Forms]![yourform]![txtcontact] & "'")

I adjusted the Dlookup statement a little but you will still have to plug in
some correct names.
the statement read something like this...
return field1 from record in table1 where field2 matched textbox1
also lookup to Dlookup in access help

you could put both in the contact text box's afterupdate event or somewere
in the cmdSearch button code.

Regards

FSt1

yomi m via AccessMonster.com said:
okay where do i put the d lookup statement. I want the form to look up
(Contact Number) on a query called (Customer Info), and send (Contact Name)
and (Organization) found into the (cmbName) and (cmb Organization) text boxes.

hi,
you could use DLookup.

Me.txtname = DLookup("[name]", "yourtabel", "[PhoneNum] = '" &
[Forms]![yourfirstform]![txtphonenum] & "'")

note: this wrapped. should be one line

I've used this technique many time to populate a form. you would need a
DLookup of each text box you want to populate.

regards
FSt1
Okay i seriously need some quick help. I have an unbound text box
(txtContact) that phone number are entered into. When i hit the command
[quoted text clipped - 5 lines]
trying to figure this out for weeks, what will the code be behind the search
button?
 
Y

yomi m via AccessMonster.com

thanks, i'll try that to see what happens
hi,
if you use DLookup, the form will not lookup anything in the query. DLookup
goes streight to the table to get the info. that is why you need a DLookup
statement for each data bit you want.
Form what you just posted, you will need 2 DLookup Statements. 1 for contact
Name and 1 for organization.

Me.cmbname = DLookup("[Contact name]", "yourTable", "[contact] = '" &
[Forms]![yourform]![txtcontact] & "'")

I adjusted the Dlookup statement a little but you will still have to plug in
some correct names.
the statement read something like this...
return field1 from record in table1 where field2 matched textbox1
also lookup to Dlookup in access help

you could put both in the contact text box's afterupdate event or somewere
in the cmdSearch button code.

Regards

FSt1
okay where do i put the d lookup statement. I want the form to look up
(Contact Number) on a query called (Customer Info), and send (Contact Name)
[quoted text clipped - 19 lines]
 
Y

yomi m via AccessMonster.com

what is "[contact] . Do i replace with muyown input?
hi,
if you use DLookup, the form will not lookup anything in the query. DLookup
goes streight to the table to get the info. that is why you need a DLookup
statement for each data bit you want.
Form what you just posted, you will need 2 DLookup Statements. 1 for contact
Name and 1 for organization.

Me.cmbname = DLookup("[Contact name]", "yourTable", "[contact] = '" &
[Forms]![yourform]![txtcontact] & "'")

I adjusted the Dlookup statement a little but you will still have to plug in
some correct names.
the statement read something like this...
return field1 from record in table1 where field2 matched textbox1
also lookup to Dlookup in access help

you could put both in the contact text box's afterupdate event or somewere
in the cmdSearch button code.

Regards

FSt1
okay where do i put the d lookup statement. I want the form to look up
(Contact Number) on a query called (Customer Info), and send (Contact Name)
[quoted text clipped - 19 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top