stLinkCriteria

B

Berny

Can anyone tell where I can get some information on the proper use and
options of 'stLinkCriteria'?

Can it you have multiple fields when using 'stLinkCriteria'?

Thanks
 
D

Douglas J. Steele

Are you talking about the variable that gets declared by the code wizard
when you want to open a form from a command button (say), so that you have
something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

stLinkCriteria can be any valid WHERE clause, without the word WHERE, so
yes, you can use multiple fields.
 
G

Guest

I have had a similar problem...when I try to use more than
one stLinkCriteria is gives the error 'Type Mismatch'. If
I use one Criteria at a time it works fine, but I need to
filter the records by more than one variable. Any advice??
 
D

Douglas J. Steele

What did you try to use as your filter? Was it, in fact, a valid Where
clause (without the word Where)?

If you're trying to use variables when building your string, you need to be
careful about where you put quotes.

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = '" & variableB &
"'"

Note that I'm assuming FieldA is a numeric field, and that FieldB is a text
field. To make it more obvious that I've got quotes for the second field,
here it is again with spaces included:

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = ' " & variableB &
" ' "
 
B

Berny

Currently I'm using the following code:

Private Sub BtnAcquire_Click()
On Error GoTo Err_BtnAcquire_Click

Dim stDocName As String
Dim stLinkBKLG As String

stDocName = "Def_Scoping"

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "'"

DoCmd.OpenForm stDocName, , , stLinkBKLG

DoCmd.Close acForm, "frmscoping", acSaveNo

Exit_BtnAcquire_Click:
Exit Sub

Err_BtnAcquire_Click:
MsgBox Err.Description
Resume Exit_BtnAcquire_Click

End Sub

How would I add the multiple fields?

Sorry, I'm new at this

Thanks
 
B

Berny

Can you please tell me what I'm doing wrong? both fields are text fields, I
can seem to get the quotes in the right place:

stLinkCriteria = "[BKLG]='" & "'" & Forms!frmscoping![BKLG] & "' and
[SBKG]='" & "'" & Forms!frmscoping![SBKG] & "'"
 
T

Tom Ross

It looks like an extra single quotes Remove "'" & in two places

stLinkCriteria = "[BKLG]='" & "'" & Forms!frmscoping![BKLG] & "' and
[SBKG]='" & "'" & Forms!frmscoping![SBKG] & "'"

Print or display your variable stlinkcriteria if for example BKLG- "bbb" and sbkg="sss" it should look like

[BKLG] = 'bbb' and [SBKG] = 'sss'

yours will probobly be

[BKLG] = ' 'bbb' and [SBKG] = ' 'sss' with an extra single quote before bbb and sss


Tom


Berny said:
Can you please tell me what I'm doing wrong? both fields are text fields, I
can seem to get the quotes in the right place:

stLinkCriteria = "[BKLG]='" & "'" & Forms!frmscoping![BKLG] & "' and
[SBKG]='" & "'" & Forms!frmscoping![SBKG] & "'"


Douglas J. Steele said:
What did you try to use as your filter? Was it, in fact, a valid Where
clause (without the word Where)?

If you're trying to use variables when building your string, you need to
be
careful about where you put quotes.

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = '" & variableB &
"'"

Note that I'm assuming FieldA is a numeric field, and that FieldB is a
text
field. To make it more obvious that I've got quotes for the second field,
here it is again with spaces included:

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = ' " & variableB
&
" ' "
 
D

Douglas J. Steele

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "' AND [XYZ]=" &
Forms!frmscoping![XYZ]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Berny said:
Currently I'm using the following code:

Private Sub BtnAcquire_Click()
On Error GoTo Err_BtnAcquire_Click

Dim stDocName As String
Dim stLinkBKLG As String

stDocName = "Def_Scoping"

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "'"

DoCmd.OpenForm stDocName, , , stLinkBKLG

DoCmd.Close acForm, "frmscoping", acSaveNo

Exit_BtnAcquire_Click:
Exit Sub

Err_BtnAcquire_Click:
MsgBox Err.Description
Resume Exit_BtnAcquire_Click

End Sub

How would I add the multiple fields?

Sorry, I'm new at this

Thanks

Douglas J. Steele said:
Are you talking about the variable that gets declared by the code wizard
when you want to open a form from a command button (say), so that you have
something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

stLinkCriteria can be any valid WHERE clause, without the word WHERE, so
yes, you can use multiple fields.
 
B

Berny

Thank you
It looks like an extra single quotes Remove "'" & in two places

stLinkCriteria = "[BKLG]='" & "'" & Forms!frmscoping![BKLG] & "' and
[SBKG]='" & "'" & Forms!frmscoping![SBKG] & "'"

Print or display your variable stlinkcriteria if for example BKLG- "bbb" and sbkg="sss" it should look like

[BKLG] = 'bbb' and [SBKG] = 'sss'

yours will probobly be

[BKLG] = ' 'bbb' and [SBKG] = ' 'sss' with an extra single quote before bbb and sss


Tom


Berny said:
Can you please tell me what I'm doing wrong? both fields are text fields, I
can seem to get the quotes in the right place:

stLinkCriteria = "[BKLG]='" & "'" & Forms!frmscoping![BKLG] & "' and
[SBKG]='" & "'" & Forms!frmscoping![SBKG] & "'"


Douglas J. Steele said:
What did you try to use as your filter? Was it, in fact, a valid Where
clause (without the word Where)?

If you're trying to use variables when building your string, you need to
be
careful about where you put quotes.

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = '" & variableB &
"'"

Note that I'm assuming FieldA is a numeric field, and that FieldB is a
text
field. To make it more obvious that I've got quotes for the second field,
here it is again with spaces included:

stLinkCriteria = "FieldA = " & variableA & " AND FieldB = ' " & variableB
&
" ' "
 
B

Berny

t
Thank you
Douglas J. Steele said:
stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "' AND [XYZ]=" &
Forms!frmscoping![XYZ]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Berny said:
Currently I'm using the following code:

Private Sub BtnAcquire_Click()
On Error GoTo Err_BtnAcquire_Click

Dim stDocName As String
Dim stLinkBKLG As String

stDocName = "Def_Scoping"

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "'"

DoCmd.OpenForm stDocName, , , stLinkBKLG

DoCmd.Close acForm, "frmscoping", acSaveNo

Exit_BtnAcquire_Click:
Exit Sub

Err_BtnAcquire_Click:
MsgBox Err.Description
Resume Exit_BtnAcquire_Click

End Sub

How would I add the multiple fields?

Sorry, I'm new at this

Thanks

Douglas J. Steele said:
Are you talking about the variable that gets declared by the code
wizard
when you want to open a form from a command button (say), so that you have
something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

stLinkCriteria can be any valid WHERE clause, without the word WHERE,
so
yes, you can use multiple fields.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Berny" <BlancoB at MSN dot Com> wrote in message
Can anyone tell where I can get some information on the proper use and
options of 'stLinkCriteria'?

Can it you have multiple fields when using 'stLinkCriteria'?

Thanks
 
B

Berny

Is there something special about passing the value of a check box?

When the box is unchecked (value 0) it appears to work fine.

However, when the box is checked (value -1) it cannot locate the records.

Any idea what I'm doing wrong?

If Len([BKLG] & "") > 2 And Len([SBKG] & "") < 3 And [PreScoped] = -1 Then
' Check for BKLG and Pre-scoped only
stLinkCriteria = "[BKLG]= '" & Me![BKLG] & "' And [PreScoped]= " &
Me![PreScoped] & ""
If DCount("Def", "QryFrmScpWr", stLinkCriteria) < 1 Then
Beep
MsgBox WrsMsg3004, vbInformation, WrsMsgBx2001
DoCmd.GoToControl "[BKLG]" ' Position
cursor in Backlog code (BKLG) Field
Exit Sub
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Douglas J. Steele said:
stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "' AND [XYZ]=" &
Forms!frmscoping![XYZ]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Berny said:
Currently I'm using the following code:

Private Sub BtnAcquire_Click()
On Error GoTo Err_BtnAcquire_Click

Dim stDocName As String
Dim stLinkBKLG As String

stDocName = "Def_Scoping"

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "'"

DoCmd.OpenForm stDocName, , , stLinkBKLG

DoCmd.Close acForm, "frmscoping", acSaveNo

Exit_BtnAcquire_Click:
Exit Sub

Err_BtnAcquire_Click:
MsgBox Err.Description
Resume Exit_BtnAcquire_Click

End Sub

How would I add the multiple fields?

Sorry, I'm new at this

Thanks

Douglas J. Steele said:
Are you talking about the variable that gets declared by the code
wizard
when you want to open a form from a command button (say), so that you have
something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

stLinkCriteria can be any valid WHERE clause, without the word WHERE,
so
yes, you can use multiple fields.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Berny" <BlancoB at MSN dot Com> wrote in message
Can anyone tell where I can get some information on the proper use and
options of 'stLinkCriteria'?

Can it you have multiple fields when using 'stLinkCriteria'?

Thanks
 
D

Douglas J. Steele

I don't see any reason why that shouldn't work. Try removing that
superfluous "" from the end of the expression.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Berny said:
Is there something special about passing the value of a check box?

When the box is unchecked (value 0) it appears to work fine.

However, when the box is checked (value -1) it cannot locate the records.

Any idea what I'm doing wrong?

If Len([BKLG] & "") > 2 And Len([SBKG] & "") < 3 And [PreScoped] = -1 Then
' Check for BKLG and Pre-scoped only
stLinkCriteria = "[BKLG]= '" & Me![BKLG] & "' And [PreScoped]= " &
Me![PreScoped] & ""
If DCount("Def", "QryFrmScpWr", stLinkCriteria) < 1 Then
Beep
MsgBox WrsMsg3004, vbInformation, WrsMsgBx2001
DoCmd.GoToControl "[BKLG]" ' Position
cursor in Backlog code (BKLG) Field
Exit Sub
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Douglas J. Steele said:
stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "' AND [XYZ]=" &
Forms!frmscoping![XYZ]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Berny said:
Currently I'm using the following code:

Private Sub BtnAcquire_Click()
On Error GoTo Err_BtnAcquire_Click

Dim stDocName As String
Dim stLinkBKLG As String

stDocName = "Def_Scoping"

stLinkBKLG = "[BKLG]=" & "'" & Forms!frmscoping![BKLG] & "'"

DoCmd.OpenForm stDocName, , , stLinkBKLG

DoCmd.Close acForm, "frmscoping", acSaveNo

Exit_BtnAcquire_Click:
Exit Sub

Err_BtnAcquire_Click:
MsgBox Err.Description
Resume Exit_BtnAcquire_Click

End Sub

How would I add the multiple fields?

Sorry, I'm new at this

Thanks

Are you talking about the variable that gets declared by the code
wizard
when you want to open a form from a command button (say), so that you have
something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

stLinkCriteria can be any valid WHERE clause, without the word WHERE,
so
yes, you can use multiple fields.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Berny" <BlancoB at MSN dot Com> wrote in message
Can anyone tell where I can get some information on the proper use and
options of 'stLinkCriteria'?

Can it you have multiple fields when using 'stLinkCriteria'?

Thanks
 

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