Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open button for single record

Status
Not open for further replies.

tania20

Programmer
Oct 30, 2006
148
AU
Hi, I have a form which shows all the records for a table.I want some way to have a button next to the fields for one record that will open another form based on one field of the selected record. I know how to achieve through using a yes/no control and applying a search criteria based on this....but to me this involves two actions as opposed to one which is not very efficient.Does anyone have any ideas to point me in the right direction?

Cheers

Tania
 
You can open a form, or report, to a single record by using:
for form:
DoCmd.OpenForm "YourFormNameHere", acViewNormal,,"[YourIDFieldOnFormYouAreOpening]=" & Me!YourKeyFieldThatMatchesUpWithTheOther

If matching text then you need to add single quotes:
DoCmd.OpenForm "YourFormNameHere", acViewNormal,,"[YourIDFieldOnFormYouAreOpening]='" & Me!YourKeyFieldThatMatchesUpWithTheOther & "'"

for a report:
DoCmd.OpenReport "YourReportNameHere", acViewPreview,,"[YourIDFieldOnFormYouAreOpening]=" & Me!YourKeyFieldThatMatchesUpWithTheOther

and the same as above using single quotes if matching text. If matching dates, use # marks instead of single quotes.


Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top