Record won't open when selected by user

G

Guest

The user chooses the Contract Name and the Contract Rate Sheet Name from
cmbContractName and cmbContractRateSheetName respectfully. Once these names
are chosen, the user clicks the command button that should take them directly
to the record they have chosen based on the Contract Name and the Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions is
tblContractRates-Specifications. Should I develop a query Vs the table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
D

Duane Hookom

If the data type of ContractName and ContractRateSheetName are numeric then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?
 
G

Guest

That's it! It was because of the numeric data type, & yes I did confirm the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

Duane Hookom said:
If the data type of ContractName and ContractRateSheetName are numeric then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
The user chooses the Contract Name and the Contract Rate Sheet Name from
cmbContractName and cmbContractRateSheetName respectfully. Once these
names
are chosen, the user clicks the command button that should take them
directly
to the record they have chosen based on the Contract Name and the Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions is
tblContractRates-Specifications. Should I develop a query Vs the table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

Ok, I'm getting a dialog box when I click. It says "The OpenForm action was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

Mary A Perez said:
That's it! It was because of the numeric data type, & yes I did confirm the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

Duane Hookom said:
If the data type of ContractName and ContractRateSheetName are numeric then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
The user chooses the Contract Name and the Contract Rate Sheet Name from
cmbContractName and cmbContractRateSheetName respectfully. Once these
names
are chosen, the user clicks the command button that should take them
directly
to the record they have chosen based on the Contract Name and the Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions is
tblContractRates-Specifications. Should I develop a query Vs the table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
D

Duane Hookom

Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Ok, I'm getting a dialog box when I click. It says "The OpenForm action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

Mary A Perez said:
That's it! It was because of the numeric data type, & yes I did confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

Duane Hookom said:
If the data type of ContractName and ContractRateSheetName are numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

The user chooses the Contract Name and the Contract Rate Sheet Name
from
cmbContractName and cmbContractRateSheetName respectfully. Once
these
names
are chosen, the user clicks the command button that should take them
directly
to the record they have chosen based on the Contract Name and the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions is
tblContractRates-Specifications. Should I develop a query Vs the
table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

Duane Hookom said:
Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Ok, I'm getting a dialog box when I click. It says "The OpenForm action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

Mary A Perez said:
That's it! It was because of the numeric data type, & yes I did confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

The user chooses the Contract Name and the Contract Rate Sheet Name
from
cmbContractName and cmbContractRateSheetName respectfully. Once
these
names
are chosen, the user clicks the command button that should take them
directly
to the record they have chosen based on the Contract Name and the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions is
tblContractRates-Specifications. Should I develop a query Vs the
table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
D

Duane Hookom

Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

Duane Hookom said:
Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully. Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs the
table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

Duane I apologize for being so ignorant, but the record source you are
referring to..is it for the form I'm trying to open with the command button?
If it is, the record source is a table not a query and the table does include
the numeric fields of the [ContractName] and [ContractRateSheetName].
The statement below with the "Where" statement is from the menu form where
the user chooses the "Contract Name" and the " Contract Rate Sheet Name".
So, if it's the "Where" statement below that you want me to place the debug
results in will it not work since it's not for the form I'm trying to open
with the command button?
Thanks again for all your patience.

Duane Hookom said:
Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

Duane Hookom said:
Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully. Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs the
table to
make the code work? As you can tell my knowledge is very limited.
Below is the code for "on click" event procedure. Below that is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
D

Duane Hookom

Your code has
Debug.Print stLinkCriteria
If you open the immediate window, you can see this value. Copy the value
into your clipboard. Then open a new, blank query and type in:

SELECT *
FROM [insert your table name here]
WHERE [insert from your clipboard here] ;

Does this work as expected?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Duane I apologize for being so ignorant, but the record source you are
referring to..is it for the form I'm trying to open with the command
button?
If it is, the record source is a table not a query and the table does
include
the numeric fields of the [ContractName] and [ContractRateSheetName].
The statement below with the "Where" statement is from the menu form where
the user chooses the "Contract Name" and the " Contract Rate Sheet Name".
So, if it's the "Where" statement below that you want me to place the
debug
results in will it not work since it's not for the form I'm trying to open
with the command button?
Thanks again for all your patience.

Duane Hookom said:
Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the
form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the
command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName
"
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

:

Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully.
Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and
the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the
frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs
the
table to
make the code work? As you can tell my knowledge is very
limited.
Below is the code for "on click" event procedure. Below that
is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

Well the query worked except it came up with "zero" value. So, I tried
stating Id Vs the name. Still the form that I want to open will not open.
I'm at a loss.

Duane Hookom said:
Your code has
Debug.Print stLinkCriteria
If you open the immediate window, you can see this value. Copy the value
into your clipboard. Then open a new, blank query and type in:

SELECT *
FROM [insert your table name here]
WHERE [insert from your clipboard here] ;

Does this work as expected?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Duane I apologize for being so ignorant, but the record source you are
referring to..is it for the form I'm trying to open with the command
button?
If it is, the record source is a table not a query and the table does
include
the numeric fields of the [ContractName] and [ContractRateSheetName].
The statement below with the "Where" statement is from the menu form where
the user chooses the "Contract Name" and the " Contract Rate Sheet Name".
So, if it's the "Where" statement below that you want me to place the
debug
results in will it not work since it's not for the form I'm trying to open
with the command button?
Thanks again for all your patience.

Duane Hookom said:
Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the
form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the
command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName
"
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

:

Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully.
Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and
the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the
frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs
the
table to
make the code work? As you can tell my knowledge is very
limited.
Below is the code for "on click" event procedure. Below that
is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

Ok, I re-did the query & yes the debug #'s when used in a query come up with
the correct result. So, how do I get the code to open up the form I need?

Duane Hookom said:
Your code has
Debug.Print stLinkCriteria
If you open the immediate window, you can see this value. Copy the value
into your clipboard. Then open a new, blank query and type in:

SELECT *
FROM [insert your table name here]
WHERE [insert from your clipboard here] ;

Does this work as expected?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Duane I apologize for being so ignorant, but the record source you are
referring to..is it for the form I'm trying to open with the command
button?
If it is, the record source is a table not a query and the table does
include
the numeric fields of the [ContractName] and [ContractRateSheetName].
The statement below with the "Where" statement is from the menu form where
the user chooses the "Contract Name" and the " Contract Rate Sheet Name".
So, if it's the "Where" statement below that you want me to place the
debug
results in will it not work since it's not for the form I'm trying to open
with the command button?
Thanks again for all your patience.

Duane Hookom said:
Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the
form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the
command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName
"
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

:

Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully.
Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and
the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the
frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs
the
table to
make the code work? As you can tell my knowledge is very
limited.
Below is the code for "on click" event procedure. Below that
is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 
G

Guest

Sorry Duane.....ignore my last 2 replies. I figured it out.
I was playing around with a "test" command button & used the wizard & came
up wiht this code & it works. Thanks so much for all your time & patience.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContractRates-Specifications"

stLinkCriteria = " [ContractRateSheetNameId]=" &
Me![cmbContractRateSheetName]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Click:
Exit Sub

Err_cmdClickforContractInformation1_Click:



Duane Hookom said:
Your code has
Debug.Print stLinkCriteria
If you open the immediate window, you can see this value. Copy the value
into your clipboard. Then open a new, blank query and type in:

SELECT *
FROM [insert your table name here]
WHERE [insert from your clipboard here] ;

Does this work as expected?

--
Duane Hookom
MS Access MVP
--

Mary A Perez said:
Duane I apologize for being so ignorant, but the record source you are
referring to..is it for the form I'm trying to open with the command
button?
If it is, the record source is a table not a query and the table does
include
the numeric fields of the [ContractName] and [ContractRateSheetName].
The statement below with the "Where" statement is from the menu form where
the user chooses the "Contract Name" and the " Contract Rate Sheet Name".
So, if it's the "Where" statement below that you want me to place the
debug
results in will it not work since it's not for the form I'm trying to open
with the command button?
Thanks again for all your patience.

Duane Hookom said:
Does the record source of your form include the fields numeric fields
[ContractName] and [ContractRateSheetName]? If so, can you open the
form's
record source in SQL view and type the results of Debug.Print
stLinkCriteria in the SQL view following " WHERE "?


--
Duane Hookom
MS Access MVP
--

No. Only the code that the user uses when making the contract name and
contract rate sheet name choices prior to the click event for the
command
button:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName
"
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName "

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

Otherwise the form itself that opens has no event happening. Now, I do
have
the frmContractRates-Specifications record source as
tblContractRates--Specifications. Should this be a query instead?

Thanks again for your help & patience.

:

Do you have any code or events happening when the form opens?

--
Duane Hookom
MS Access MVP
--

Ok, I'm getting a dialog box when I click. It says "The OpenForm
action
was
cancelled".
Here's the code:
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " AND [ContractRateSheetName]=" _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Any suggestions?

:

That's it! It was because of the numeric data type, & yes I did
confirm
the
values are correct.
You are a saint!
Thanks so much for your patience & all your help!

:

If the data type of ContractName and ContractRateSheetName are
numeric
then
your code would be:

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=" & cmbContractName _
& " And [ContractRateSheetName] = " _
& cmbContractRateSheetName
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub

Have you confirmed you have the values 34 and 109 in the table?

--
Duane Hookom
MS Access MVP
--

message
The user chooses the Contract Name and the Contract Rate Sheet
Name
from
cmbContractName and cmbContractRateSheetName respectfully.
Once
these
names
are chosen, the user clicks the command button that should take
them
directly
to the record they have chosen based on the Contract Name and
the
Contract
Rate Sheet Name from frmContractRates-Specifications.
However, it filters a blank record from
frmContractRates-Specifications.
Currently the record source for the
frmContractRates-Specificaions
is
tblContractRates-Specifications. Should I develop a query Vs
the
table to
make the code work? As you can tell my knowledge is very
limited.
Below is the code for "on click" event procedure. Below that
is
the
"DeBug" info I'm receiving.
Thanks for your patience and help.
Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[ContractName]=""" & cmbContractName _
& """ And [ContractRateSheetName] = """ _
& cmbContractRateSheetName & """"
Debug.Print stLinkCriteria

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub


Debug Info:
[ContractName]="34" And [ContractRateSheetName] = "109"
 

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