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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with stLinkCriteria between 2 forms

Status
Not open for further replies.

AccessDevJunior

Programmer
Apr 14, 2004
81
0
0
GB
I have put this code on the double click event of a list box but it dosent work, i want it to open up another form linking the reference number, so that the form opens up with the same reference number as the reference number that has focus on the list box.


Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Edit User Input"
stLinkCriteria = "[forms]![frm_Edit User Input]![Reference Number]=" & "'" & Me![Reference Number] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Does anyone know where im going wrong?
 
The WhereCondition of the openreport method of the docmd object, is an SQL where clause without the keyword WHERE, so basically a field name, some operator and a criterion (or multiple and/or...)

[tt]stLinkCriteria = "fieldname = '" & Me![Reference Number] & "'"[/tt]

- replace "fieldname" with the name of the field in the forms recordsource on which you filter.

Roy-Vidar
 
Im not sure what you want me to do, ive changed the code to the below and it still does not work?

stLinkCriteria = "[Reference Number] = '" & Me![Reference Number] & "'"

the 2 forms record source im trying to link each comes from a query
 
Some clouds in my crystall ball, so I've no idea what "...and it still does not work?" means. You're still going to keep us guessing what the error is, and the rest of the relevant info (bound column, name, datatypes...)? Have a look at faq181-2886, which addresses how to get the best answers (#14, but the whole faq is worth a read)

Roy-Vidar
 
Hi RoyVidar!

This is the thread that got me past my first error (the fact that it was SQL completely left me, so i wasn't includingt he single quotes), but now that i've gotten that straightened out "... it still doesn't work" ;)

by that i mean, i get no errors, and my report prints, but it's blank, only formating and headers, no data according to the employee badge i think i've selected.

Here's my code, what am i doing wrong?

Code:
    Dim stDocName As String
    Dim stDocCondition As String
    
    stDocName = "rptPersView_Quals"
    stDocCondition = "BADGE = '" & Me.cmbBadge.Value & "'"
    'stLinkCriteria = "[Reference Number] = '" & Me![Reference Number] & "'"

    DoCmd.OpenReport stDocName, acNormal, , stDocCondition


Becky,
Ft. Rucker
 
Possibly, 1 the control does not contain any value (Null), 2 there's no record matching the value in the control - have you saved the record prior to invoking the report?

[tt]docmd.runcommand accmdsaverecord[/tt]

Else, don't know.

Roy-Vidar
 
If badge is a numeric field then you don't need the single quotes.

stDocCondition = "BADGE = " & Me.cmbBadge.Value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top