Opening a Form and Setting CheckBox to 'Yes'

schreinman

Registered User.
Local time
Yesterday, 21:22
Joined
Oct 2, 2010
Messages
24
Hello!

I am opening a separate form from a main form with:

DoCmd.OpenForm "frmName"

Is there a way that I can set a Yes/No box in the newly opened form to 'Yes' when it is opened?

Beginner question; I have looked for an answer with no luck.

Thanks for your help!
 
After the DoCmd.Open you can use:
Code:
Forms!FormNameHere.CheckBoxNameHere = True
 
Beautiful; thanks Bob!

How about opening the form to a new record when I am not in "Data Entry" mode? Can that be done? (should I start a new post?)
 
Beautiful; thanks Bob!

How about opening the form to a new record when I am not in "Data Entry" mode? Can that be done? (should I start a new post?)
You can use OpenArgs to tell it what to do.

So, in the DoCmd.OpenForm code you use

Code:
DoCmd.OpenForm "FormNameHere", OpenArgs:="AddNew"

and then in that form's On Load event you can use:

Code:
If Me.OpenArgs <> "" Then
   If Me.OpenArgs = "AddNew" Then
      If Not Me.NewRecord Then
         Docmd.RunCommand acCmdRecordsGoToNew
      End If
   End If
End If

There might be a more concise way but that's what I have at the moment.
 

Users who are viewing this thread

Back
Top Bottom