Display message

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
784
Office Version
  1. 365
Hi,

I have customer form and a Review Rate button to open RateDisplay form so when they are looking at a company they can review the rate for this company by clicking the Review Rate button.

This is the code:

Code:
Private Sub ReviewRate_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_ReviewRate_Click

    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer
    Dim strDocName As String, strLinkCriteria As String

    ' If CompanyName control is blank, display a message.
    If IsNull(Me![Combo54]) Then
        strMsg = "Select the Company/company record whose rates you want to see, then press the Review Rate button again."
        intStyle = vbOKOnly
        strTitle = "Select a Company"
        MsgBox strMsg, intStyle, strTitle
        Me![Combo54].SetFocus
    Else
    ' Otherwise, open Rate Display form, showing products for current supplier.
        strDocName = "RateDisplay"
        strLinkCriteria = "[CompanyID] = Forms![CUSTOMERS]![COMPANYID]"
        DoCmd.OpenForm strDocName, , , strLinkCriteria
        DoCmd.MoveSize (1440 * 0.78), (1440 * 1.8)
      
    End If
    
Exit_ReviewProducts_Click:
    Exit Sub
    
Err_ReviewProducts_Click:
    MsgBox Err.Description
    Resume Exit_ReviewRate_Click
End Sub
how can i add to this code another line of code to display a message there's not rate for this company and don't open the RateDisplay form, when this company doesn't have rate yet?

thank you
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Thank you so much, worked great, even though still opening the form but at least display message not Rate data to display.

Thank you
 
Upvote 0
Thank you so much, worked great, even though still opening the form but at least display message not Rate data to display.

Thank you


Did you cleam up the code to remove the duplicate lines below?

Code:
        strDocName = "RateDisplay"
        DoCmd.OpenForm strDocName, , , strLinkCriteria
        DoCmd.MoveSize (1440 * 0.78), (1440 * 1.8)


You only want to keep the lines that are within the IF ... Then statment with the DCount().
 
Upvote 0
thanks


But i tried removing the lines and will not work, would you mind pasting the whole code for me, the way it should be?

Thank you
 
Upvote 0
thanks


But i tried removing the lines and will not work, would you mind pasting the whole code for me, the way it should be?

Thank you

Since you have been modifying your code,I have not seen the more current versions.

Please post your VBA code. This way I can see if I can spot the problem.
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,128
Members
451,743
Latest member
matt3388

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