Need help setting up stLinkCriteria for multiple values

B

BZeyger

Hello,

I have an Access Database that consists of many forms. If a users selects a
record, it needs to look at the tech ID and Source Data ID of a record to
open a new form.

I currently have:

stLinkCriteria = "[Tech Manual ID]=" & Forms![TMINS vs Source Data (mainform
- filter by project)]![Tech Manual ID]


The entire code is

stDocName = "Bib Data Mainform"

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdRefresh
stLinkCriteria = "[Tech Manual ID]=" & Forms![TMINS vs Source Data
(mainform - filter by project)]![Tech Manual ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

I am having trouble with the statement.
I would like it to open the form with the Tech Manual ID and Source Data ID
stored from the record selected.

What should I have as the stLinkCriteria?

Thanks for your time
 
J

John W. Vinson

Hello,

I have an Access Database that consists of many forms. If a users selects a
record, it needs to look at the tech ID and Source Data ID of a record to
open a new form.

I currently have:

stLinkCriteria = "[Tech Manual ID]=" & Forms![TMINS vs Source Data (mainform
- filter by project)]![Tech Manual ID]


The entire code is

stDocName = "Bib Data Mainform"

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdRefresh
stLinkCriteria = "[Tech Manual ID]=" & Forms![TMINS vs Source Data
(mainform - filter by project)]![Tech Manual ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

I am having trouble with the statement.
I would like it to open the form with the Tech Manual ID and Source Data ID
stored from the record selected.

What should I have as the stLinkCriteria?

Thanks for your time

stLinkCriteria should be a valid SQL query WHERE clause without the word
WHERE. If you can create a Query that returns the records you want, open it in
SQL view to see what the WHERE clause looks like. I'm *guessing* it will be

stLinkCriteria = "[Tech Manual ID]=" & Forms![TMINS vs Source Data (mainform -
filter by project)]![Tech Manual ID] & " AND [Source Data ID] = " &
Forms![TMINS vs Source Data (mainform - filter by project)]![Source Data ID]

This assumes that the ID values are numeric (otherwise you need quotemarks
around them).

I would recommend simplifying your form name. Access can get confused if
object names contain special punctuation such as parentheses and hyphens, and
the compiled size of your query will be smaller if you use simpler names. I'd
also avoid using blanks in fieldnames, since blanks will make it harder to
upsize to SQL/Server (not impossible but more work). You can use a form's
Caption property to display frmTMins3 as "TMINS vs Source Data (mainform -
filter by product)" if you wish.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top