DoCmd.OpenForm problem

J

Jeff C

I am using the followiing in the OnOpen Event of a form designated as the
Startup form when the database opens. The record source for the form is a
simple table with a field named user and a field named form. Me.txtUser has
a default value pulling the user name from an environment variable.

Problem is trying to get DoCmd.OpenForm [Forms]![Startup].[txtForm],
acNormal to work. txtForm is the field form in the record source. I want
the form named in this field to open and evidently my syntax is wrong.

Dim USER As DAO.Recordset
Set USER = Me.RecordsetClone

USER.FindFirst "[User] = '" & Me.txtUSER & "'"

If USER.NoMatch Then

MsgBox "No Match", vbOKOnly
DoCmd.OpenForm "Green", acNormal

Else

MsgBox "Match"
DoCmd.OpenForm [Forms]![Startup].[txtForm], acNormal

End If

Can anyone resolve this? Thank you.
 

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

Top