Using a variable with the bang operator?

C

cseifferly

How would I rework this code so that I can use variables with it?

DoCmd.OpenForm "frmReportsMenu", acDesign
Forms!frmReportsMenu.cmdClose.Picture = "I:\Bid Administration\bids.ico"
DoCmd.Close acForm, "frmReportsMenu", acSaveYes

I'd like to create a loop to open all of the forms I have specified in a
table.

Crystal
 
T

tina

assuming your table of form names is called tblForms, and the field holding
the form names is called FormName, try something along the following lines,
as

Dim rst As DAO.Recordset, str As String

Set rst = CurrentDb.OpenRecordset("tblForms", dbOpenDynaset)
rst.MoveFirst

Do
str = rst("FormName")
DoCmd.OpenForm str, acDesign
Forms(str).cmdClose.Picture = "I:\Bid Administration\bids.ico"
DoCmd.Close acForm, str, acSaveYes
rst.MoveNext
Loop Until rst.EOF

rst.Close
Set rst = Nothing

hth
 
Top