Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error trap not trapping

Status
Not open for further replies.

elizabeth

IS-IT--Management
Sep 16, 1999
1,196
US
I have a form which has a button to open a related form. The 1st form is an inventory item, the 2nd form is the PO for that item (and possibly add'l items). In many cases, no PO has not been entered yet. If I try to open the form based on a linking POID, I get <br><i>Run-time error '3075':<br>Syntax error (missing operator) in query expression 'QuoteID ='</i><br><br>I thought I had fixed this with the following code months ago, but just noticed this is not working. Any ideas? TIA.<br><br>Private Sub cmdPO_Click()<br>On Error GoTo Err_cmdPO_Click<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stDocName As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stLinkCriteria As String<br><br>&nbsp;&nbsp;&nbsp;&nbsp;stDocName = &quot;frmPO&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.RunCommand acCmdSaveRecord<br>&nbsp;&nbsp;&nbsp;&nbsp;stLinkCriteria = &quot;[POID]=&quot; & Me![POID]<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenForm stDocName, , , stLinkCriteria<br><br>Exit_cmdPO_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br><br>Err_cmdPO_Click:<br>&nbsp;&nbsp;&nbsp;&nbsp;If Err.Number = 3075 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Enter a value in this field to display details.&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub
 
Well that is a doozie (sp?)&nbsp;&nbsp;Hmmm. I assume the button you are clicking on to open the form is still called cmdPO. Are any other subs coming into play that you are not showing? This button click is not being called by another button click is it? Silly but change the error trap to this:<br><br>Select Case Err.Number<br>Case 3075<br>&nbsp;&nbsp;&nbsp;MsgBox &quot;Enter a value in this field to display details.&quot;<br>&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>Case Else<br>&nbsp;&nbsp;&nbsp;MsgBox Err.Description<br>&nbsp;&nbsp;&nbsp;Resume Exit_cmdPO_Click<br>End Select&nbsp;&nbsp;&nbsp;&nbsp;<br><br>I would also test an err.raise in there to see if you can raise your own error. <br><br>Your code looks like it should be working. You can also try to delete the button and recreate it.<br>end select&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
 
1. Yes button is named cmdPO.<br>2. No, this is the only code involved.<br>3. Tried the case stmt, same result (nada), same message.<br>4. Tried err.raise - if i put it after the line:<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenForm stDocName, , , stLinkCriteria<br>I get same result, same message.<br>If I put it after that line, I get the the same number, but slightly more generic message:<br><i>Application-defined or object-defined error. </i><br><br>Thanks for the suggestions - I'll try anything! Any other ideas? BTW, this is happening on 3 separate buttons that open 3 similar forms. In the meantime I'll try recreating the button just in case there was some corruption.
 
GUESS WHAT! I found this code still works perfectly in my 97 version of this application! It is exactly the same. I also deleted and recreated the button in case t was corrupted but it still doesn't work. Is there any differences in error trapping in version 2000?
 
Did you import the form from the 97 database? (bad) Did you convert the 97 database to 2000? (good)<br><br>Have you tried to recreate the Form itself? (ouch)<br><br>Do you have all the References that you need set in Tools, References?<br><br>
 
1. converted (good)! But while I'm at it I'll try importing, <i>just in case!</i><br>2. Big big ouch. Complex form. But I'll do it if I can't find any other solution...<br>3. Are you aware of any particular reference I need for this code? Currently I've got references set to:<br><br>Visual Basic for Applications<br>MS Access 9.0 Lib<br>OLE Automation<br>MS DAO 3.6 Lib<br>MS VBA for extensibility 5.3
 
Solved. My own dumb fault for somehow turning on the &quot;Break on All Errors&quot; option&nbsp;&nbsp;instead of &quot;Break on Unhandled Errors&quot;. It's under Tools/Options/General -this option only displays when you are actually in the VB code editor. Time for the Ginko Biloba!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top