Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Does this make sense (A2k SR1)

    The code below , if selecting yes from the msgbox, is suppose to enter a tick (true) into [NoneFault].
    If No, [fault]=true

    Every time I create a new record, the tick from the previous record is removed.
    Can any one see why.




    Private Sub cmbInsurerCode_Exit(Cancel As Integer)
    If Me.NoneFault = False And Me.Fault = False Then
    Dim intButSelected As Integer, intButType As Integer
    Dim strMsgPrompt As String, strMsgTitle As String
    strMsgPrompt = "Is This A None Fault Case ?"
    strMsgTitle = "!!"
    intButType = vbYesNo + vbDefaultButton1
    intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
    If intButSelected = vbYes Then
    Forms!frmdetails!NoneFault = True
    Forms!frmdetails!NoneFault.Visible = True
    RunCommand acCmdSaveRecord
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strValue As String
    Set db = CurrentDb
    strSQL = "Select * From tblTPDetails Where tblTPDetails.estimateno = " & Forms!frmdetails!EstimateNo
    Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
    If rst.RecordCount = 0 Then
    DoCmd.OpenForm "frmFaultDetails"
    DoCmd.GoToRecord acDataForm, "frmFaultDetails", acNewRec
    Forms!frmFaultdetails!EstimateNo.SetFocus
    Forms!frmFaultdetails!EstimateNo = Forms!frmdetails!EstimateNo
    Else
    strValue = Forms!frmdetails!EstimateNo
    DoCmd.OpenForm "frmFaultDetails", acViewNormal, , "EstimateNo = " & strValue
    End If
    If intButSelected = vbNo Then
    Forms!frmdetails!Fault = True
    Forms!frmdetails!Fault.Visible = True
    End If
    End If
    End If
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Does this make sense (A2k SR1)

    Dave,

    I don't see anything in this code that would set NoneFault to false. Perhaps there is other code in your database that does that. However, I noticed that the If intButSelection = vbNo Then ... End If block is nested within the If intButSelection = vbYes Then ... End If block, so it will never be executed. In fact, you don't need If intButselection = vbNo Then, you can handle this in the Else part of the outer block:

    Private Sub cmbInsurerCode_Exit(Cancel As Integer)
    If Me.NoneFault = False And Me.Fault = False Then
    Dim intButSelected As Integer, intButType As Integer
    Dim strMsgPrompt As String, strMsgTitle As String
    strMsgPrompt = "Is This A None Fault Case ?"
    strMsgTitle = "!!"
    intButType = vbYesNo + vbDefaultButton1
    intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
    If intButSelected = vbYes Then
    Forms!frmdetails!NoneFault = True
    Forms!frmdetails!NoneFault.Visible = True
    RunCommand acCmdSaveRecord
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strValue As String
    Set db = CurrentDb
    strSQL = "Select * From tblTPDetails Where tblTPDetails.estimateno = " & Forms!frmdetails!EstimateNo
    Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
    If rst.RecordCount = 0 Then
    DoCmd.OpenForm "frmFaultDetails"
    DoCmd.GoToRecord acDataForm, "frmFaultDetails", acNewRec
    Forms!frmFaultdetails!EstimateNo.SetFocus
    Forms!frmFaultdetails!EstimateNo = Forms!frmdetails!EstimateNo
    Else
    strValue = Forms!frmdetails!EstimateNo
    DoCmd.OpenForm "frmFaultDetails", acViewNormal, , "EstimateNo = " & strValue
    End If
    Else
    Forms!frmdetails!Fault = True
    Forms!frmdetails!Fault.Visible = True
    End If
    End If
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does this make sense (A2k SR1)

    Hans.
    Heres the rest of the code from this particular Combo.
    I feel maybe it's the on enter code that may be upsetting things, what do you think.

    Private Sub cmbInsurerCode_AfterUpdate()
    If Me.JobType = "Insurer" Then
    Forms![frmdetails]![sbfINSURERDETAILS]![Insurer code] = Me.cmbInsurerCode.Column(0)
    Forms![frmdetails]![sbfINSURERDETAILS]![Insurer] = Me.cmbInsurerCode.Column(1)
    Forms![frmdetails]![sbfINSURERDETAILS]![insurer address] = Me.cmbInsurerCode.Column(2)
    Forms![frmdetails]![sbfINSURERDETAILS]![insurer tel] = Me.cmbInsurerCode.Column(3)
    Forms![frmdetails]![sbfINSURERDETAILS]![insurer fax] = Me.cmbInsurerCode.Column(4)
    'Me.JobType = "Insurer"
    Forms!frmdetails.Refresh
    End If
    End Sub
    ##########################################
    Private Sub cmbInsurerCode_NotInList(NewData As String, Response As Integer)
    Dim strSQL As String, x As Integer
    Dim LinkCriteria As String
    Dim strMsgTitle As String
    Dim stDocName As String
    strMsgTitle = "!!"
    stDocName = "frmInsurerQuickFind"
    x = MsgBox("Do You Want To Add This Insurer To The Database?", vbYesNo, strMsgTitle)
    If x = vbYes Then
    strSQL = "Insert Into tblinsurer ([insurercode]) values ('" & NewData & "')"
    'MsgBox strsql
    CurrentDb.Execute strSQL, dbFailOnError
    LinkCriteria = "[insurercode] = '" & Me!cmbInsurerCode.Text & "'"
    DoCmd.OpenForm "frminsureradmin", , , LinkCriteria
    Response = acDataErrAdded
    Else
    Response = acDataErrContinue
    DoCmd.OpenForm stDocName
    End If
    End Sub
    #########################################
    Private Sub cmbInsurerCode_Enter()
    If IsNull([cmbInsurerCode]) And Forms!frmdetails!JobType = "Insurer" Then
    DoCmd.OpenForm "frmInsurerQuickFind"
    End If
    End Sub
    #######################################
    Private Sub cmbInsurerCode_Exit(Cancel As Integer)
    If Me.NoneFault = False And Me.Fault = False Then
    Dim intButSelected As Integer, intButType As Integer
    Dim strMsgPrompt As String, strMsgTitle As String
    strMsgPrompt = "Is This A None Fault Case ?"
    strMsgTitle = "!!"
    intButType = vbYesNo + vbDefaultButton1
    intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
    If intButSelected = vbYes Then
    Forms!frmdetails!NoneFault = True
    Forms!frmdetails!NoneFault.Visible = True
    RunCommand acCmdSaveRecord
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strValue As String
    Set db = CurrentDb
    strSQL = "Select * From tblTPDetails Where tblTPDetails.estimateno = " & Forms!frmdetails!EstimateNo
    Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
    If rst.RecordCount = 0 Then
    DoCmd.OpenForm "frmFaultDetails"
    DoCmd.GoToRecord acDataForm, "frmFaultDetails", acNewRec
    Forms!frmFaultdetails!EstimateNo.SetFocus
    Forms!frmFaultdetails!EstimateNo = Forms!frmdetails!EstimateNo
    Else
    strValue = Forms!frmdetails!EstimateNo
    DoCmd.OpenForm "frmFaultDetails", acViewNormal, , "EstimateNo = " & strValue
    End If
    Else
    Forms!frmdetails!Fault = True
    Forms!frmdetails!Fault.Visible = True
    End If
    End If
    End Sub
    ######################################
    Private Sub cmbInsurerCode_DblClick(Cancel As Integer)
    Dim LinkCriteria As String
    Dim stDocName As String
    Dim stLinkCriteria As String
    LinkCriteria = "[insurercode] = '" & Me!cmbInsurerCode.Text & "'"
    stDocName = "frmInsurerQuickFind"
    If IsNull([cmbInsurerCode]) Then
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Else
    DoCmd.OpenForm "frminsureradmin", , , LinkCriteria
    End If
    End Sub
    ############################################
    Private Sub cmbInsurerCode_KeyDown(KeyCode As Integer, Shift As Integer)
    'If KeyCode = vbKeyDown Then Me.cmbClientCode.SetFocus
    'If KeyCode = vbKeyUp Then Me.CmbRegistration.SetFocus
    If KeyCode = vbKeyF11 Then
    If Me.cmbInsurerCode.ListIndex > 0 Then
    Me!cmbInsurerCode.ListIndex = Me!cmbInsurerCode.ListIndex - 1
    End If
    End If
    If KeyCode = vbKeyF12 Then
    If Me.cmbInsurerCode.ListIndex < Me.cmbInsurerCode.ListCount - 1 Then
    Me!cmbInsurerCode.ListIndex = Me!cmbInsurerCode.ListIndex + 1
    End If
    End If
    If KeyCode = vbKeyF2 Then Call cmbInsurerCode_DblClick(1)
    If KeyCode = vbKeyF5 Then Me.DummyEst.SetFocus
    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Does this make sense (A2k SR1)

    Again, I see nothing in the code that would set Fault or NoneFault to false.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does this make sense (A2k SR1)

    Fault & None Faults default values are false.
    The code won't run unless this condition is met

    If Me.NoneFault = False And Me.Fault = False Then #######"Run the code "########



    Further to my last post, I remmed out all other procedures other than the On Exit.
    I also changed the order :-
    Forms!frmDetails!NoneFault.visible=true
    Forms!frmDetails!NoneFault=true

    This didn't work neither.
    Whats happening is evrytime a new record is created, the previous records tick bos is set to false

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Does this make sense (A2k SR1)

    Are you using a continuous form? Is the control unbound? The combination of those two conditions will exhibit the behavior you're describing because there is really only *one* checkbox for that control, even though it appears to show up in every record.
    Charlotte

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does this make sense (A2k SR1)

    No its not Continous.

    I've commented the code perhaps it will make better sense:

    Private Sub cmbInsurerCode_Exit(Cancel As Integer)
    '=====================================
    'check to see if check box's are false
    If Me.NoneFault = False And Me.Fault = False Then
    '=====================================

    '========================================
    'if the condition is met then run the code
    Dim intButSelected As Integer, intButType As Integer
    Dim strMsgPrompt As String, strMsgTitle As String
    'create msgbox to give the user an option.FAULT OR NOT
    strMsgPrompt = "Is This A None Fault Case ?"
    strMsgTitle = "!!"
    intButType = vbYesNo + vbDefaultButton1
    intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
    If intButSelected = vbYes Then
    '==================================
    'if yes then make Nonefault visible
    Forms!frmdetails!NoneFault.Visible = True
    '==================================
    'put tick in box
    Forms!frmdetails!NoneFault = True
    '===================================
    'save record
    RunCommand acCmdSaveRecord
    '====================================
    'create SQL query and open the Fault Details form for data entry, checking if Estimate
    'number already exists
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim strValue As String
    Set db = CurrentDb
    strSQL = "Select * From tblTPDetails Where tblTPDetails.estimateno = " & Forms!frmdetails!EstimateNo
    Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
    If rst.RecordCount = 0 Then
    DoCmd.OpenForm "frmFaultDetails"
    DoCmd.GoToRecord acDataForm, "frmFaultDetails", acNewRec
    Forms!frmFaultdetails!EstimateNo.SetFocus
    Forms!frmFaultdetails!EstimateNo = Forms!frmdetails!EstimateNo
    Else
    '================================================= ================================
    ' if EstimateNo already exists, go to here and open the form on the correct record
    strValue = Forms!frmdetails!EstimateNo
    DoCmd.OpenForm "frmFaultDetails", acViewNormal, , "EstimateNo = " & strValue
    End If
    Else
    '================================================= ================================
    'this should activate if the No button is pressed setting Fault to true instead of Nonefault
    'perhaps this is where things are conflicting
    Forms!frmdetails!Fault.Visible = True
    Forms!frmdetails!Fault = True
    End If
    End If
    End Sub

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Does this make sense (A2k SR1)

    Dave, I don't think that the problem is caused by the code you've posted up to now. There are instructions that set NoneFault or Fault to True (it doesn't matter whether you do this before or after making the check box visible), but none that set them to False.

    You say that the problem only occurs when a new record is created. So if I were you, I would look at the code that is executed when a new record is created - it could be in the BeforeInsert or AfterInsert of the form. Or, if you open another (popup) form when a new record is created, it could be code in that form.

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does this make sense (A2k SR1)

    Sometimes you can't see for looking.
    I have the false statements, as you said, elsewhere.
    It works ok now.
    Thanks Hans & Charlotte for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •