Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parameter behind command button code (Access 2003)

    I have this code OnClick of a command button
    DoCmd.TransferText acImportFixed, "CAP 2007", "SPECIALTY CAP ", _
    "R:SMGR HMOS 2009AETNA 2009 MAR 2009CAP FILESSPECIALTY CAPG0034V00.txt", False, ""

    Every month I have to go into the code and change the month (using Find/Replace)

    Is there a way to have this use a parameter so that when I click the button it asks for the Month? [Enter Month]

    I know this works in a query, but I don't recall seeing how this would work in a form.

    Thank you !

    Michael

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

    Re: Parameter behind command button code (Access 2003)

    Try this:

    Dim strMonth As String
    strMonth = InputBox("Enter 3 letter abbreviation for month.")
    If Not Len(strMonth) = 3 Then
    MsgBox "Invalid - try again.", vbExclamation
    Exit Sub
    End If
    DoCmd.TransferText acImportFixed, "CAP 2007", "SPECIALTY CAP ", _
    "R:SMGR HMOS 2009AETNA 2009" & strMonth & " 2009CAP FILESSPECIALTY CAPG0034V00.txt", False

    I assumed that the space before Mar was a mistake and the space after it intentional. Modify as needed.

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Parameter behind command button code (Access 2003)

    Thank you Hans. I totally forgot about InputBox.

    Much appreciated !!

    Michael

Posting Permissions

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