[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

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

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
SteveL13
Asked:
SteveL13
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
use the current event of the form

me.command0.visible=dcount("*","NameOF2ndTable", "JobN=" & me.txtJobN)>0
0
 
SteveL13Author Commented:
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
 
borkiCommented:
You can add a where condition to the form, such as:

DoCmd.OpenForm("frmsecondOne",,,"JobN=" & me.txtJobN)
0
 
Rey Obrero (Capricorn1)Commented:
private sub command0_click()

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

end sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now