Link to home
Start Free TrialLog in
Avatar of wlwebb
wlwebbFlag for United States of America

asked on

Access - vbYesNo

Good evening (or morning wherever you may be)...

Have a bit of code that I've never done much with.  I needed a Msgbox to come up and ask for a Yes/No answer and do some code part of which goes to another tab for some checkbox selections, if it was yes.. that part is working.

However, if I click NO, I want it to cancel and return to the same tabbed form where I started.  It's still opening the other tabbed form.

The command button that starts all of this is on Page1 which is:
Forms![frm_DataReporting]![LVLReportingTypeSelect].Form!
If the Yes/No gets selected as NO then it needs to return to this form.


This is the code for the Command button that starts my code.
Private Sub cmdClearChip_Click()
    Dim LResponse As Integer, lngMyRptgSeqID As Integer, lngMyShiftRptgLVLCtlID As Integer, i As Integer
    
    Dim strCriteria As String
    
    LResponse = MsgBox("You selected Clear Chip Reporting.  Are you sure this is a WV Lottery Clear Chip reporting?" & vbNewLine & vbNewLine & _
    "PLEASE NOTE: You must select the particular Machine or Machines that are being Clear Chipped.  Check the box of any Machine that the Lottery is performing a Clear Chip!", vbYesNo, "CLEAR CHIP REPORTING")
    
    Me.cboSelectedLVLRptgType.RowSource = "SELECT LVLRptgTypeID, LVLRptgType FROM LVLReportingType WHERE (((LVLRptgType)=" & "'Clear Chip'" & "))" & ";"
    Me.cboSelectedLVLRptgType = Me.cboSelectedLVLRptgType.ItemData(0)

Application.Echo False
    
    Call NewLVLControl
    lngMyRptgSeqID = GetMyShiftSeqID()
    lngMyShiftRptgLVLCtlID = GetMyShiftRptgLVLCtlID()
    
    CurrentDb.Execute "INSERT INTO ShiftReportingEndCountCtl (ShiftRptgLVLCtlID, CountType) VALUES (" & lngMyShiftRptgLVLCtlID & "," & 3 & ")", dbFailOnError
    
    Call GenerateLVLMachineLines3(LResponse = vbYes)
        
    Parent.Page4.SetFocus
    Forms![frm_DataReporting]![ShiftReportingLVL].Form![AmtOut].SetFocus
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.Requery
    strCriteria = "[ShiftRptgLVLCtlID] = " & lngMyShiftRptgLVLCtlID
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.Filter = strCriteria
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.FilterOn = True
        
    Parent.Page1a.SetFocus
    Parent.Page1a.Visible = True
        
        i = 10
    
        Do Until i = Val(Forms![frm_DataReporting]![LVLReportingTypeSelect].Form![txtNbrMachines])
 
        Forms![frm_DataReporting]![ClearChipSelectMachines].Controls("lblCkBox" & i).Visible = False
        Forms![frm_DataReporting]![ClearChipSelectMachines].Controls("CkBox" & i).Visible = False
        i = i - 1
        Loop
    
Application.Echo True

End Sub

Open in new window


AND This is the Yes Answer part (at least as I understand it it's the Yes part)
Private Sub GenerateLVLMachineLines3(IsClearChip As Boolean)
Dim bytCounter As Byte, lngMyRptgSeqID As Long, lngMyShiftRptgLVLCtlID As Long, i As Integer, z As Integer
Dim strSQL As String

lngMyRptgSeqID = GetMyShiftSeqID()
lngMyShiftRptgLVLCtlID = GetMyShiftRptgLVLCtlID()
    
    i = 1   ' This counter is for Inserting Active Currency Seq to End Count tbl
    z = DMax("ShiftEndCountCtlID", "ShiftReportingEndCountCtl", "ShiftEndCountCtlID")
    
    CurrentDb.Execute "UPDATE ShiftReportingLVLCtl SET ClearChipReporting=" & True & " WHERE ShiftRptgLVLCtlID= " & lngMyShiftRptgLVLCtlID, dbFailOnError
    
    Do Until bytCounter = Me.txtNbrMachines
        bytCounter = bytCounter + 1
    CurrentDb.Execute "INSERT INTO ShiftReportingLVL (LVLPositionNbr, RptgSeqID) VALUES (" & bytCounter & "," & lngMyRptgSeqID & ")", dbFailOnError
    Loop
    
    Do While i <= Forms![frm_DataReporting]![LVLReportingTypeSelect].Form![txtCntAllActiveDenominations]
        strSQL = "INSERT INTO ShiftReportingEndCountDetails (ShiftEndCountCtlID, DenominationID) SELECT " & z & ", DenominationID FROM [qry_Denomination_All_Active] WHERE [AllActiveDenominationSeq]= " & i
        CurrentDb.Execute strSQL, dbFailOnError
        i = i + 1
    Loop

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wlwebb

ASKER

PERFECT!!! Thank you!