Hi there
(Can DoCmd.openform allow formname from stored string value?)

I am needing to vary the FormName part of the .openform based on a result looked up in another table. as I have 10 Different forms that will be specific to a certain kind of record.

My code something like this:

Dim NewFrmName

NewFrmName = Dlookup ~~~looks up the form name from table
'so NewFrmName will end up NewFrmName = Frm_RepairParts or something

DoCmd.OpenForm NewFrmName, acNormal, "", "", acAdd, acNormal

End Sub.

Error I get is "the action or method required a form name argument"
so it does not like my NewFrmName variable and need another way of doing this.

anyone know a way to do what I am wanting ??
many thanks

I'll answer my own question here !!!

I just figured it out. Dohh

Just need to put [ ] around the form variable. then its fine, open the correct form per lookup result !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.