Help with VBA Code

Dr_Worm

Board Regular
Joined
Jul 28, 2003
Messages
103
Need help with the following formula o_O :cool:

What it's meant to do is if there is nothing in [Quote Number] on the main form and someone clicks on the additional information button a message box opens and the "Additional_Tender_Information" Form doesn't open :oops:

Code:
Private Sub Additional_Tender_Information_Click()
On Error GoTo Err_Additional_Tender_Information_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
If [Quote Number] = IsNull Then
    DoCmd.Beep
    Report_NoData

Else
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

    stDocName = "Tender Information"
    
    stLinkCriteria = "[Quote Number]=" & "'" & Me![Quote Number] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
End If

Exit_Additional_Tender_Information_Click:
    Exit Sub

Err_Additional_Tender_Information_Click:
    MsgBox Err.Description
    Resume Exit_Additional_Tender_Information_Click
    
End Sub
Private Sub Report_NoData()

    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer
    
    strMsg = "Status needs to be on 'Requires Approval' to Print this Report."
    intStyle = vbOKOnly
    strTitle = "Print Error"
    
    MsgBox strMsg, intStyle, strTitle

End Sub
:coffee:
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try and see if this works, you use IsNull as a function, not as a comparison, as a Null value is unknown, nothing can equate to it, not even another Null. Also, consider removing any embedded spaces in your column or table names, they can cause a lot of problems.

Code:
Private Sub Additional_Tender_Information_Click() 
On Error GoTo Err_Additional_Tender_Information_Click 

    Dim stDocName As String 
    Dim stLinkCriteria As String 
    
If IsNull[Quote Number] Then 
    DoCmd.Beep 
    Report_NoData 

<snip>
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,719
Members
451,666
Latest member
GCS1998

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top