G
Gargoyle
Having a problem with a form in Access2003.
I keep getting "Error 2501: The OpenForm action was canceled"
Two tables as follows:-
tbl_ITEM_LISTINGS
ItemID [Primary Key]
ItemListingSeq [Primary Key]
ItemListingNumber
DateListed
. . . etc . . .
tbl_TRANSACTIONS
TransactionID [Primary Key]
ItemListingNumber
. . . etc . . .
There is a One-to-One relationship between the two tables on
"ItemListingNumber".
The two tables have corresponding forms "frm_ITEM_LISTINGS" (a Continuous
Form) and "frm_TRANSACTIONS" (a Single Form).
On the "frm_ITEM_LISTINGS" there is a button alongside each detail row, which
when clicked is coded thus:-
Private Sub btnTransactions_Click()
On Error GoTo Err_btnTransactions_Click
strProcedureName = "btnTransactions_Click"
lngProcedureLoc = 100
If Nz(Me!ItemListingNumber, "") = "" Then
Call ShowWarn("Transactions only allowed on recorded listing", "Missing
Listing Number")
Exit Sub
End If
Dim stDocName As String, stLinkCriteria As String
stDocName = "frm_TRANSACTIONS"
lngProcedureLoc = 200
stLinkCriteria = "ItemListingNumber = " & Me.ItemListingNumber.Value
lngProcedureLoc = 300
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnTransactions_Click:
Exit Sub
Err_btnTransactions_Click:
MsgBox "Error: " & Err.Number & " - " & Err.Description & vbCrLf _
& "Object: " & conObjectName & vbCrLf _
& "Process: " & strProcedureName & vbCrLf & "Location: " &
lngProcedureLoc, vbCritical
Resume Exit_btnTransactions_Click
End Sub
When the message "Error 2501: The OpenForm action was canceled" appears,
clicking on the debug button highlights the line (from above):-
DoCmd.OpenForm stDocName, , , stLinkCriteria
I have used Debug.Print to check that the stLinkCriteria is set to a valid
value
(ItemListingNumber = 85774993 in my example, which corresponds to the
ItemListingNumber.Value of 85774993 on form "frm_ITEM_LISTINGS").
I cannot understand why this error is happening. I am using similar techniques
for other related forms which open just fine.
It's probably something blindingly obvious, but I'm now at the "wood for the
trees" state.
Can anyone help please?
I keep getting "Error 2501: The OpenForm action was canceled"
Two tables as follows:-
tbl_ITEM_LISTINGS
ItemID [Primary Key]
ItemListingSeq [Primary Key]
ItemListingNumber
DateListed
. . . etc . . .
tbl_TRANSACTIONS
TransactionID [Primary Key]
ItemListingNumber
. . . etc . . .
There is a One-to-One relationship between the two tables on
"ItemListingNumber".
The two tables have corresponding forms "frm_ITEM_LISTINGS" (a Continuous
Form) and "frm_TRANSACTIONS" (a Single Form).
On the "frm_ITEM_LISTINGS" there is a button alongside each detail row, which
when clicked is coded thus:-
Private Sub btnTransactions_Click()
On Error GoTo Err_btnTransactions_Click
strProcedureName = "btnTransactions_Click"
lngProcedureLoc = 100
If Nz(Me!ItemListingNumber, "") = "" Then
Call ShowWarn("Transactions only allowed on recorded listing", "Missing
Listing Number")
Exit Sub
End If
Dim stDocName As String, stLinkCriteria As String
stDocName = "frm_TRANSACTIONS"
lngProcedureLoc = 200
stLinkCriteria = "ItemListingNumber = " & Me.ItemListingNumber.Value
lngProcedureLoc = 300
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnTransactions_Click:
Exit Sub
Err_btnTransactions_Click:
MsgBox "Error: " & Err.Number & " - " & Err.Description & vbCrLf _
& "Object: " & conObjectName & vbCrLf _
& "Process: " & strProcedureName & vbCrLf & "Location: " &
lngProcedureLoc, vbCritical
Resume Exit_btnTransactions_Click
End Sub
When the message "Error 2501: The OpenForm action was canceled" appears,
clicking on the debug button highlights the line (from above):-
DoCmd.OpenForm stDocName, , , stLinkCriteria
I have used Debug.Print to check that the stLinkCriteria is set to a valid
value
(ItemListingNumber = 85774993 in my example, which corresponds to the
ItemListingNumber.Value of 85774993 on form "frm_ITEM_LISTINGS").
I cannot understand why this error is happening. I am using similar techniques
for other related forms which open just fine.
It's probably something blindingly obvious, but I'm now at the "wood for the
trees" state.
Can anyone help please?