Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2012
    Posts
    85

    Unanswered: calling a function on check box selected.

    hey, on my form i select a table, then check a box, either, txt or excel.
    Then i call an import function based on which is checked.

    how would i write my code to do this? this is what i currently have:

    Code:
    If me.txtfile = true Then Call txtimport
    Else
    If me.excel - true Then Call excelimport
    End If
    End If
    this doesnt work, I believe i am misusing the If function. thanks in advance
    Mike
    ________

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Are these Checkboxes independent, or are they part of an Option Group?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Jun 2012
    Posts
    85
    option group, you can only select one
    Mike
    ________

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Then you have to refer to the Option Group, which the Access Gnomes always name FrameX, with X being a number, rather than the individual Checkboxes!

    Assuming that the first Option is for the txtfile, the second one is for excel, and there are only the two Options

    Code:
    Private Sub Frame7_AfterUpdate()
     
     If Me.Frame7 = 1 Then
      Call txtimport
     Else
      Call excelimport
     End If
    
    End Sub


    But I really prefer using the Select Case construct for this kind of thing

    Code:
    Private Sub Frame7_AfterUpdate()
    
    Select Case Me.Frame7
     
     Case 1
      Call txtimport
     
     Case 2
      Call excelimport
    
    End Select
    
    End Sub


    Note that this doesn't address the issue of passing the name of the document or spreadsheet to the function you're calling. I assume that you've taken this into account already.

    Linq ;0)>
    Last edited by Missinglinq; 08-09-12 at 20:01.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Jun 2012
    Posts
    85
    yes thank you very much works! appreciate the help!!!
    Mike
    ________

Posting Permissions

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