I have two tables: Invoices & Organisations. A form called Invoices contains a field [Organisation Code] that is used to populate about 14 fields in the 65-fields form. The form is unbound (no Record Source) & so are its fields. With some help, I've gone as far as to develop the following VBA code but I'm not sure how to run it. I'd appreciate any help you can throw my way, please.
=======================================
Private Sub LoadInfo_Click()
' Pull info out of SQL View.
Dim db As Database
Dim rs As Recordset
Dim tmpUser As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * FROM db
rganisations " & _
"WHERE [Organisation Code] = '" & Me.[Organisation Code] & "'")
Me![Organisation Type] = rs![Organisation Type]
Me!Organisation = rs!Organisation
Me![Organisation Phone] = rs![Organisation Phone]
Me![Organisation Fax] = rs![Organisation Fax]
Me!Department = rs!Department
Me!Street = rs!Street
Me!Suburb = rs!Suburb
Me!State = rs!State
Me!Country = rs!Country
Me![Contact Title] = rs![Contact Title]
Me![Contact First Name] = rs![Contact First Name]
Me![Contact Surname] = rs![Contact Surname]
Me![Contact Position] = rs![Contact Position]
Me![Contact MOB] = rs![Contact MOB]
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub Invoice_Period_To_AfterUpdate()
Me.[Invoice Period To] = Me.[Invoice Period From] + Me.[Days in Period]
End Sub
=======================================
Private Sub LoadInfo_Click()
' Pull info out of SQL View.
Dim db As Database
Dim rs As Recordset
Dim tmpUser As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * FROM db

"WHERE [Organisation Code] = '" & Me.[Organisation Code] & "'")
Me![Organisation Type] = rs![Organisation Type]
Me!Organisation = rs!Organisation
Me![Organisation Phone] = rs![Organisation Phone]
Me![Organisation Fax] = rs![Organisation Fax]
Me!Department = rs!Department
Me!Street = rs!Street
Me!Suburb = rs!Suburb
Me!State = rs!State
Me!Country = rs!Country
Me![Contact Title] = rs![Contact Title]
Me![Contact First Name] = rs![Contact First Name]
Me![Contact Surname] = rs![Contact Surname]
Me![Contact Position] = rs![Contact Position]
Me![Contact MOB] = rs![Contact MOB]
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub Invoice_Period_To_AfterUpdate()
Me.[Invoice Period To] = Me.[Invoice Period From] + Me.[Days in Period]
End Sub