Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    214

    Unanswered: If check box is true, then a corresponding combo box is required

    I have a check box that if checked, I want a corresponding combo box to be required before moving onto the next record.

    I have created command buttons to go the prev and next record and attempted to tie in code at this point to check if the check box was true then then the combobox must have a value or it would not advance to the next record. I am new to vb, so I am not sure what I am doing wrong. Below is a sample of my code. Currently, it will advance to the next record no matter what.

    Private Sub Command85_Click()

    If Located = True And Combo75 = Null Then

    Dim nextrec As String
    nextrec = MsgBox("You have not chosen a located result", vbCritical)

    Else

    On Error GoTo Err_Command85_Click

    DoCmd.GoToRecord , , acNext

    Exit_Command85_Click:
    Exit Sub

    Err_Command85_Click:
    MsgBox Err.Description
    Resume Exit_Command85_Click

    End If

    End Sub

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    hide

    the navigating buttons(.visible = false) until your conditions are met
    Dale Houston, TX

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    or after the update of the checkbox then
    set the focus on the other control.
    After update of that control check your values of the controls - if the conditions are not met then
    the code behind the button (advance record button) should be something like

    If mycheckbox = true and not isnull(mylistbox ) then
    do code here
    else
    Dale Houston, TX

  4. #4
    Join Date
    Feb 2004
    Posts
    214

    ...

    Is already had the visibile when true coded in, but the IsNull() worked perfectly. Thank you very much!

  5. #5
    Join Date
    Jul 2006
    Posts
    108
    Code:
    Private Sub Command85_Click()
    
    If Located = True And Combo75 = Null Then
    
    Dim nextrec As String
    nextrec = MsgBox("You have not chosen a located result", vbCritical)
    
    Else
    
    On Error GoTo Err_Command85_Click
    
    DoCmd.GoToRecord , , acNext
    
    Exit_Command85_Click:
    Exit Sub
    
    Err_Command85_Click:
    MsgBox Err.Description
    Resume Exit_Command85_Click
    
    End If
    
    End Sub
    ^^thats alot of writing for \/\/


    Code:
    if located.value = true AND combo75.value = "" then
    MsgBox("You have not chosen a located result", vbCritical)
    else
    DoCmd.GoToRecord , , acNext
    endif


    **however i must add that when i was working with prev. and next record buttons i had a problem with getting an ERr msg for
    not being able to goto next record or something along those lines
    Last edited by jwalker343; 08-28-07 at 17:26.

Posting Permissions

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