• Parameter behind command button code (Access 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Parameter behind command button code (Access 2003)

    Author
    Topic
    #457070

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1144756

      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.

      • #1144767

        Thank you Hans. I totally forgot about InputBox.

        Much appreciated !!

        Michael

    Viewing 0 reply threads
    Reply To: Reply #1144756 in Parameter behind command button code (Access 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel