Autopopulate a form based on a single field?

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

Guest

I have a problem. I am needing to modify an existing form to auto populate
things like name address and contact information by inputing a telephone
number in the form?
I'm pretty sure this can be done I'm just not sure exactly how to do this.
Could I do this via a macro or will I need to do something more?
I have looked up a few things that apparently this can be done via a combo
box but the database is too large to have a combo box to work. Any advice
that acn be given on this will be a great help.

Thank you.
 
A phone number isn't always a reliable "key field" to identify your
customers. You should use a more unique number, like an autonumber, or
"autonumber-like" field.
But that's another matter...

I take it your creating multiple records against varoius customers...
sort of like multiple invoices.

Be aware that you don't have to save the customer information fields when
you create multiple records against that customer. All you have to save is
the PhoneNo on each record. That's all you need to identify the customer.
Just "display" the other info on the form as a guide to the user.
Just create a subform with all your customer info fields (including the
PhoneNo), and link it to the PhoneNo field on your main form via that
PhoneNo.
hth
Al Camp
 
Dim rs As Object
If you are looking for the main form to be populated with the record that
corresponds to the telephone number and, as Al has stated .. this must be a
unique field .. (in other words only 1 record will have this telephone
number), then add the following code in the AfterUpdate event of the
telephone textbox.
Note: replace [TelephoneNo] with the name of your field (in the table or
query)
replace txtTelephoneNo with the name of your textbox that's on the form
This works with Access XP .. if you're using an older version let me know &
I'll revise it.

***
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[TelephoneNo] = " & Me!txtTelephoneNo
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If

Set rs = Nothing
***

HTH
Connie
 
oops
ignore that 1st line (Dim rs As Object) - it's down further in the code
section.
sorry


Connie said:
Dim rs As Object
If you are looking for the main form to be populated with the record that
corresponds to the telephone number and, as Al has stated .. this must be a
unique field .. (in other words only 1 record will have this telephone
number), then add the following code in the AfterUpdate event of the
telephone textbox.
Note: replace [TelephoneNo] with the name of your field (in the table or
query)
replace txtTelephoneNo with the name of your textbox that's on the form
This works with Access XP .. if you're using an older version let me know &
I'll revise it.

***
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[TelephoneNo] = " & Me!txtTelephoneNo
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If

Set rs = Nothing
***

HTH
Connie


Hinchen said:
I have a problem. I am needing to modify an existing form to auto populate
things like name address and contact information by inputing a telephone
number in the form?
I'm pretty sure this can be done I'm just not sure exactly how to do this.
Could I do this via a macro or will I need to do something more?
I have looked up a few things that apparently this can be done via a combo
box but the database is too large to have a combo box to work. Any advice
that acn be given on this will be a great help.

Thank you.
 
Back
Top