Using Where Parameters in DoCmd to Open Unbound Form (1 Viewer)

BlingGirl

New member
Local time
Today, 03:59
Joined
Apr 11, 2020
Messages
19
I have an unbound form called WeeklyUpdates where the user can select criteria and then open a couple of other forms.
I am trying to create buttons to open the unbound WeeklyUpdates form using the where condition in DoCmd.OpenForm.

The unbound WeeklyUpdates form has three checkboxes, New, Activate, and Cancel. I had the OnOpen event setting the values for these three checkboxes to false. Once one of the three boxes is checked the other two checkboxes enabled value got set to false, ensuring the user can only check one box at a time. I felt it was sufficient.

However, the boss has requested that I create 4 buttons, one that opens the form with the default of having no boxes checked and 3 additional buttons to open with one of each of the three checkboxes already checked as default.

I first changed the DoCmd.Open form where criteria to "[New] = True AND [Active] = False AND [Cancel] = False" but once the form opened the OnOpen event kicked in and all their values returned to False.

So I removed the OnOpen event and have tried various ways of programming the buttons. All three checkboxes are opening solid (null). (BTW the triple state property value is set to no.) I am guessing it's because it is an unbound form. Is there a way to do this?
1665517254647.png
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 11:59
Joined
Sep 21, 2011
Messages
14,311
The where is for record criteria. As your form is unbound, there are none, surely?
Pass in your options in OpenArgs, and process whatever is passed in.
 

moke123

AWF VIP
Local time
Today, 06:59
Joined
Jan 11, 2013
Messages
3,920
Checkboxes should be equal to False or 0.
Use the openargs argument to pass the desired checkbox to set to -1
 

BlingGirl

New member
Local time
Today, 03:59
Joined
Apr 11, 2020
Messages
19
Yes, @Gasman I should have realized as I was writing all of those statements I was referencing non-existent records.
I have only been using Access since April and am slowly learning by reading in forums and watching YouTube videos. So sometimes it takes me a bit before I have the palm-to-forehead moment.

I have never done anything with OpenArgs....until today!
I had to Google OpenArgs but found it was pretty simple for me to grasp from the MS website.
I set the default values to 0, used New, Cancel and Activate as OpenArgs, and wrote a boolean statement on the OpenForm event, and boom! Thank you both so much!!
 
Last edited:

moke123

AWF VIP
Local time
Today, 06:59
Joined
Jan 11, 2013
Messages
3,920
Once one of the three boxes is checked the other two checkboxes enabled value got set to false, ensuring the user can only check one box at a time. I felt it was sufficient.
You can also use an option group to do this.
 

BlingGirl

New member
Local time
Today, 03:59
Joined
Apr 11, 2020
Messages
19
@moke123 I have not used option groups either. Thanks for letting me know, I will definitely I will add it to my growing list of things to learn to do and use in Access!
 

Users who are viewing this thread

Top Bottom