stLinkCriteria

N

Nora

This is/are my code(s)....
____________________________________________________________________
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Tender Record"
stLinkCriteria = "
Code:
= " & "'" & Me![Code] & "' And [Reg No]= " & "'"
& Me![GQ No] & "' Or [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command4_Click:
Exit Sub
Err_Command4_Click
____________________________________________________________________

Another:
stLinkCriteria2 = "[Code]= " & "'" & Me![Code] & "' And [Reg No]= " & "'" &
Me![GQ No] & "' And [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria2
____________________________________________________________________

(1)
How to combine these 2 criterias? So, the condition is if the 1st criteria
fails to display the record(s), the 2nd criteria will open the form "Tender
Record".

(2)
The idea is ([Part] & Me![Part]) is an optional filter textbox. If there is
an input, the result will display ONLY 1 record. Otherwise fixed at 1 record
only or 2~ 3 or more records with the same code & key nos. (here are "Code" &
GQ No").
____________________________________________________________________

Please help. I'm desparate.

Regards,
NH
 
M

Marshall Barton

Nora said:
This is/are my code(s)....
____________________________________________________________________
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Tender Record"
stLinkCriteria = "
Code:
= " & "'" & Me![Code] & "' And [Reg No]= " & "'"
& Me![GQ No] & "' Or [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command4_Click:
Exit Sub
Err_Command4_Click
____________________________________________________________________

Another:
stLinkCriteria2 = "[Code]= " & "'" & Me![Code] & "' And [Reg No]= " & "'" &
Me![GQ No] & "' And [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria2
____________________________________________________________________

(1)
How to combine these 2 criterias? So, the condition is if the 1st criteria
fails to display the record(s), the 2nd criteria will open the form "Tender
Record".

(2)
The idea is ([Part] & Me![Part]) is an optional filter textbox. If there is
an input, the result will display ONLY 1 record. Otherwise fixed at 1 record
only or 2~ 3 or more records with the same code & key nos. (here are "Code" &
GQ No").[/QUOTE]


Not sure what you want here, but give this a try:

stLinkCriteria = "Code= '" & Me!Code _
& "' And [Reg No]= '" & Me![GQ No] & "' "

If Not IsNull(Me!Part) Then
stLinkCriteria = stLinkCriteria _
& " And Part= '" & Me!Part & "' "
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
N

Nora

:) THANK YOU SO MUCH, MR MARSH :)
YOU DID IT!!

Marshall Barton said:
Nora said:
This is/are my code(s)....
____________________________________________________________________
Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Tender Record"
stLinkCriteria = "
Code:
= " & "'" & Me![Code] & "' And [Reg No]= " & "'"
& Me![GQ No] & "' Or [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command4_Click:
Exit Sub
Err_Command4_Click
____________________________________________________________________

Another:
stLinkCriteria2 = "[Code]= " & "'" & Me![Code] & "' And [Reg No]= " & "'" &
Me![GQ No] & "' And [Part]= " & "'" & Me![Part] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria2
____________________________________________________________________

(1)
How to combine these 2 criterias? So, the condition is if the 1st criteria
fails to display the record(s), the 2nd criteria will open the form "Tender
Record".

(2)
The idea is ([Part] & Me![Part]) is an optional filter textbox. If there is
an input, the result will display ONLY 1 record. Otherwise fixed at 1 record
only or 2~ 3 or more records with the same code & key nos. (here are "Code" &
GQ No").[/QUOTE]


Not sure what you want here, but give this a try:

	stLinkCriteria = "Code= '" & Me!Code _
								& "' And [Reg No]= '" & Me![GQ No] & "' "

	If Not IsNull(Me!Part) Then
		stLinkCriteria = stLinkCriteria _
												& " And Part= '" & Me!Part & "' "
	End If
	DoCmd.OpenForm stDocName, , , stLinkCriteria
[/QUOTE]
 

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