Autofilling Fields

TRWguy

New member
Local time
Today, 10:13
Joined
Jul 5, 2002
Messages
8
I have part of a form that deals with work orders that is company information. I want to be able to type in the name of a company and have all the related fields fill in automaticly if that company was entered in the form earlier. How do i do this?

Thank You to who ever can help
 
Create a query that looks up the company details from the name of the company entered. Then make a sub form displaying the address of the information related to the company choosen from this query.

Sometimes known as a Master and a Child Form.

HTH

Russ
 
The query must have the related field from the MANY side of the relationship and all the other fields from the ONE side, except the related field.
 
I'm not sure what you were trying to say about the relationships in your last post, but if your not worried about having multiple addresses for the same company, I can share with you how I have done something similar in the past.

After update of the company field, do the following:
Code:
Private Sub CompanyName_AfterUpdate()
If Not IsNull(CompanyName) Then
    Dim RSC As Recordset
    Set RSC = Me.RecordsetClone
    
    With RSC
    .FindFirst "[CompanyName] = '" & Me![CompanyName] & "'"
        If CompanyName = .Fields("CompanyName") Then
        Address = .Fields("Address")
        City = .Fields("City")
        State = .Fields("State")
        Zip = .Fields("Zip")
        End If
    End With
    
    Set RSC = Nothing
End If
End Sub
It would take some more coding, but you could also use .findnext to try to figure out if more than one address was used for the same company.
 

Users who are viewing this thread

Back
Top Bottom