• 0

[Access] Passing A Variable From a Form to a Query


Question

Okay,

This is really annoying me now if was in PHP I could do it in two seconds but Access is getting the better of me.

I have a form lets call it A I have a query lets call it B I want a field in A to be part of the B query. I do not know how to do it any ideas?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

You can always put a temporary query behind a button on the form then you can make the query in the code

Set Db = CurrentDb
Set qdef = Db.CreateQueryDef("temp")
sqlStr = "SELECT * FROM Table_Name WHERE ID = " & Forms(<formname>).txtField.Value & ";"

qdef.SQL = sqlStr

DoCmd.SetWarnings False

DoCmd.OpenQuery "temp", acViewNormal, acReadOnly

CurrentDb.QueryDefs.Delete ("temp")

DoCmd.SetWarnings True

qdef.Close
Db.Close

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.