Using a variable with the bang operator?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top