View Full Version : Auto update of form feilds ???? ?? ? ? ?


paulmcdonnell
06-23-2001, 04:21 AM
Hi guys,

I'm trying to update a group of fields on a form based on the value I select from a combo box. I want to select the company from my combo box then I want the five form field below it to automatically fill with the five lines of it's address stored in the table.

Just can't quite seem to get this one right...

lwhite
06-23-2001, 05:36 AM
You can use an event procedure after update in the drop down box. An example of this procedure is:
Dim dbf As Recordset, qdf As QueryDef, strSQL As String
strSQL = "SELECT * FROM [Purchases] WHERE " _
& "[Product ID] = " & Me![Product ID]
Set dbf = CurrentDb.OpenRecordset(strSQL)
Me![Product Name] = dbf![Product Name]
Me![List Price] = dbf![List Price]
Me![Per Gallon] = dbf![Per Gallon]
Me![Per Quart] = dbf![Per Quart]
Me![Per Pint] = dbf![Per Pint]
Me![Per Ozs] = dbf![Per Ozs]
Me![Per ton] = dbf![Per ton]
Me![Per Lbs] = dbf![Per Lbs]
Me![Per Acre] = dbf![List Price]

End Sub
This updates fields determined by Product ID.