Here's a function that will do a lookup of the Manufacturer's Name for any report or form. To use it simply include a field with it's control source as MfgID from any table that includes it and edit box with it's control source set to =GetMfgName(MfgID) . Or you could send a constant as a parameter instead of MfgID by enclosing it in quotes. Of course you can use the code as a model for a lookup of any field in any table by changing table and field names. |
Listing 7
Dim ThisDB As Database Dim tblRead As Recordset Dim TempCode As String Dim TempNameStr As String Dim SQLstr As String |
`Database assumed open `to hold recordset `MfgID code from recordset `MfgName from recordset ` holds SQL statement | ||||||||
` Protect against empty string parameter If IDCode <> " " Then | |||||||||
| |||||||||
Else
|
End of Listing 7
Return to Beginning Previous |
This document authored by Pat Tyler Copyright July 1997 |