General discussion

Locked

Access 97, auto-populating form fields?

By Pmfphd ·
I am trying to build a form in Access 97 that will automatically populate address, city, state, and zipcode values based on selecting a company from a dropdown. I have tried to use SetValue and connected the field to a query to select the correct value from the tables, but I get an error when the macro runs that says the query is not a part of the application. Can anyone suggest the correct approach here?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Comments

Collapse -

Access 97, auto-populating form fields?

by john_wills In reply to Access 97, auto-populatin ...

I have many such forms. One selects a client by SSN(the key) or surname, and uses these event procedures:
Private Sub FindByLastName_AfterUpdate()
Dim rs As Object
Me.Filter = ""
Set rs = Me.Recordset.Clone
rs.findfirst "[SSN]='" & Me.FindByLastName & "'"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub FindBySSN_AfterUpdate()
Dim rs As Object
Me.Filter = ""
Set rs = Me.Recordset.Clone
rs.findfirst "[SSN]='" & Me.FindBySSN & "'"
Me.Bookmark = rs.Bookmark
End Sub
I have no macro. There is a query for each drop-down, with SSN as bound column in both, and a larger one for form data.

Collapse -

Access 97, auto-populating form fields?

by Shanghai Sam In reply to Access 97, auto-populatin ...

Poster rated this answer

Collapse -

Access 97, auto-populating form fields?

by fernstar In reply to Access 97, auto-populatin ...

If you have a combo box from which the user selects the Company, it is quite simple to populate other fields.
Firstly ensure that the Company combo box has all the fields you require to populate the form.
Then on the after update event of the Company combo box you can refer to the fields associated with the company - like state etc. by referring to cboCompany.Column(1) this will give you the value in the second column associated with the selected Company. So you can then say,
Me!txtState = Me!cboCompany.Column(1)
If you do not want to display all the other fields in the combo box simply make their length zero in the parameter specifi\ying the column widths.

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums