Problem with blank/null DataErr & 'OpenForm Action cancelled'

G

Guest

Upfront disclaimer: I'm an Access newbie, though experienced in other
programming environments/languages.
I'm trying to fix a database for a friend, over the weekend, so any quick
answers would be hugely appreciated.
When I invoke a certain form directly from 'Forms' it works fine.
When I invoke it through a button on another form, I get 'The OpenForm
action was cancelled.'
When I try to debug the latter by interrogating DataErr I find that it's
null / blank.
The argument that I'm passing has the values in it that I expect, @ runtime.
Code follows:
Private Sub Pro_Bono_Button3_Click()
On Error GoTo Err_Pro_Bono_Button3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Pro Bono Attorney"

stLinkCriteria = "[DB CLIENT #]=" & "'" & Me![DB CLIENT #] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Pro_Bono_Button3_Click:
Exit Sub

Err_Pro_Bono_Button3_Click:
MsgBox "DB Client # = " & Me![DB CLIENT #] & "'"
MsgBox "Standard Doc Name = " & stDocName & "'"
MsgBox "Standard Link Criteria = " & stLinkCriteria & "'"
MsgBox "Error Code = " & DataErr & "'"
MsgBox Err.Description
Resume Exit_Pro_Bono_Button3_Click

End Sub

I tried compacting the database, per a suggestion to someone else receiving
the same err message but a 2501 err code, to no avail. Thoughts / suggestions?

Thank you!
Tom Wheeler
 
G

Guest

Hi, Tom.

The WHERE clause criteria you are passing to the form assumes that the DB
CLIENT # column is a string. If it's a numerical value, then the form won't
open, because the OnOpen( ) event will be cancelled. Try:

stLinkCriteria = "[DB CLIENT #] = " & Me![DB CLIENT #].Value

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

Perfect!
(Duh, blush...)

'69 Camaro said:
Hi, Tom.

The WHERE clause criteria you are passing to the form assumes that the DB
CLIENT # column is a string. If it's a numerical value, then the form won't
open, because the OnOpen( ) event will be cancelled. Try:

stLinkCriteria = "[DB CLIENT #] = " & Me![DB CLIENT #].Value

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Tom Wheeler said:
Upfront disclaimer: I'm an Access newbie, though experienced in other
programming environments/languages.
I'm trying to fix a database for a friend, over the weekend, so any quick
answers would be hugely appreciated.
When I invoke a certain form directly from 'Forms' it works fine.
When I invoke it through a button on another form, I get 'The OpenForm
action was cancelled.'
When I try to debug the latter by interrogating DataErr I find that it's
null / blank.
The argument that I'm passing has the values in it that I expect, @ runtime.
Code follows:
Private Sub Pro_Bono_Button3_Click()
On Error GoTo Err_Pro_Bono_Button3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Pro Bono Attorney"

stLinkCriteria = "[DB CLIENT #]=" & "'" & Me![DB CLIENT #] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Pro_Bono_Button3_Click:
Exit Sub

Err_Pro_Bono_Button3_Click:
MsgBox "DB Client # = " & Me![DB CLIENT #] & "'"
MsgBox "Standard Doc Name = " & stDocName & "'"
MsgBox "Standard Link Criteria = " & stLinkCriteria & "'"
MsgBox "Error Code = " & DataErr & "'"
MsgBox Err.Description
Resume Exit_Pro_Bono_Button3_Click

End Sub

I tried compacting the database, per a suggestion to someone else receiving
the same err message but a 2501 err code, to no avail. Thoughts / suggestions?

Thank you!
Tom Wheeler
 

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