Avatar of SteveL13
SteveL13
Flag for United States of America asked on

Don't allow new record to be added from a form if a command buttin was not clicked

I have a form which has a command button on it.  This may seem strange but I do not want the user to be able to add a record from the form if the command button was not clicked while entering data in the current record.  I do want a message box to appear letting them know they have to click the command button.

However, the command button is only visible IF certain criteria was met in another field, a combobox field, on the form named "cboToWH".  The value in that combobox has to be "AT" (without the quotes in order for this event making the user click the command button to take place.

How can I do this?

--Steve
Microsoft Access

Avatar of undefined
Last Comment
Norie

8/22/2022 - Mon
SteveL13

ASKER
To further explain...  here is my code:

Private Sub cmdAddRec_Click()
On Error GoTo Err_cmdAddRec_Click
   
    If Me.cboToWH = "AT" And Me.chkbxRedButton.DefaultValue = False Then
        MsgBox "Since this is a shipment for Tijuana you must click the red button!"
        Me.chkbxRedButton.SetFocus
    End If
   
   
    DoCmd.RunCommand acCmdSaveRecord

    DoCmd.GoToRecord , , acNewRec
    Me.cboPartN.SetFocus
    Me.txtJobN.TabStop = False
    Me.txtDateEntered.TabStop = False
    Me.txtDateDue.TabStop = False
    Me.txtPOn.TabStop = False
    Me.cboToWH.TabStop = False
    Me.txtCarrier.TabStop = False
    Me.txtProN.TabStop = False
    Me.txtWHlocation = ""
    Me.Command67.Visible = False

Exit_cmdAddRec_Click:
    Exit Sub

Err_cmdAddRec_Click:
    MsgBox Err.Description
    Resume Exit_cmdAddRec_Click
   
End Sub


So, after the "Me.chkbxRedButton.SetFocus" line I want the form to stop and wait for the user to click the command button.  How do I do this?
ASKER CERTIFIED SOLUTION
Norie

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy