Open Form With User Selection (1 Viewer)

Devorde

New member
Local time
Today, 02:56
Joined
Jun 18, 2021
Messages
6
Hello. I am brand new to Access. I have taken a beginner to advanced online course so I think I have a good base knowledge to start with. I am building an intricate database and I am currently stuck. I have created most of my tables, some forms, queries, reports & macros.

I have a menu with the command button "Run Job Info Form" which opens the Job List Name Form. I have a list box of all the job names, an OK button and an Exit button. The exit button works (pretty simple). I cannot figure out how to make the OK button do what I need to do.

I need the user to click on a job name, click ok, have the button open another form and apply the user selection (as a filter?) so that the form only pulls information for that job (it will be pulling from two or three tables using the same selection criteria). I would truly appreciate any help with this. I have looked at input boxes, macros, queries, VBA, and I just cannot figure it out!

Thanks!
 

plog

Banishment Pending
Local time
Today, 01:56
Joined
May 11, 2011
Messages
10,718
Most likely you will use DoCmd.OpenForm:


It allows you to open a form and apply a filter while doing so. Give it a read and then a shot. If you have trouble, post back here what you've tried.
 

Ranman256

Well-known member
Local time
Today, 02:56
Joined
Apr 9, 2015
Messages
4,003
to open a form using the current ID key you are on:
docmd.openform "fNewForm",,,"[id]=" & txtID
 

Devorde

New member
Local time
Today, 02:56
Joined
Jun 18, 2021
Messages
6
Thanks everyone! I will do both (read about it and use the command). I'll let you know if it works!
 

Devorde

New member
Local time
Today, 02:56
Joined
Jun 18, 2021
Messages
6
Okay. I read the article and tried to combine the information there with the line of VBA provided. When I test run the VBA, I get an error. When I test run the ok button, it asks me for a macro. (There is a definite possibility that my form is not formatted correctly and that relationships are not properly defined. Hoping to at least get it to open the form first and trouble shoot field errors on the form immediately after.) Help!

Run RHI Job List = button on PPE Database Menu Form
Opens RHI Job Name Form which has a list box, OK button & Exit button
Currently, the Run Job Info Form and Exit button perform correctly

Fields with info in list box are RHI Job Name and Company Name.

I am attaching a snip of the VBA error
 

Attachments

  • VBA error - open form using selection as filter.png
    VBA error - open form using selection as filter.png
    34.2 KB · Views: 187

Users who are viewing this thread

Top Bottom