Solved

Make command button visible if record exists in a 2nd table

Posted on 2011-09-08
4
331 Views
Last Modified: 2013-11-05
I have a command button on a form which has a query as its record source.  The query comes from a table that has a number field as its key field.  The name of the field in the table is "JobN" and there is a field on the form named "txtJobN" which has the key table field as its control source.

The command button by default is not visible.  But I want it to become visible if there is a like entry in a second table.  This second table has a key field identical to the key field in the 1st table.  What would the code be for the onopen (or would it be oncurrent?) event of the form?

Then, when the command button becomes visible and is clicked, I want a form to open to display the record in the second table.

What is my onclick event for the command button?

--Steve
0
Comment
Question by:SteveL13
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36505437
use the current event of the form

me.command0.visible=dcount("*","NameOF2ndTable", "JobN=" & me.txtJobN)>0
0
 

Author Comment

by:SteveL13
ID: 36505486
Good so far...

And then,

When the command button becomes visible and is clicked, I want a form to open to display the record in the second table.

What is my onclick event for the command button?

0
 
LVL 9

Expert Comment

by:borki
ID: 36505568
You can add a where condition to the form, such as:

DoCmd.OpenForm("frmsecondOne",,,"JobN=" & me.txtJobN)
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36505735
private sub command0_click()

docmd.openform "form2",,,"JobN=" & me.txtJobN

end sub
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question