General discussion

  • Creator
    Topic
  • #2316269

    Access VBA coding problem

    Locked

    by mark ·

    Can anyone help me please?? I have a field on an Access report called “Company name”. I have a command button in place that runs VBA code. This code is suppose to trap the text input of the user and then store in on the report field called “Company Name”. How ever when I click the button and fire the code, I get an error message telling me that the field name is incorrect, or renamed or deleted. My code reads as follows:

    Private Sub Command159_Click()
    On Error GoTo Err_Command159_Click

    Dim stDocName As String

    stDocName = “Order Questionaire”
    DoCmd.OpenReport stDocName, acPreview

    Dim MyPrompt As String
    InputBox “Enter Company Name:”

    Me!MyPrompt = [Company Name]

    Exit_Command159_Click:
    Exit Sub

    Err_Command159_Click:
    MsgBox Err.Description
    Resume Exit_Command159_Click

    End Sub

    Any idea’s? It’s worth a case of beer to someone!

All Comments

  • Author
    Replies
    • #3380173

      Not Enough Info

      by jackofalltech ·

      In reply to Access VBA coding problem

      1. Inputbox won’t do you any good unless you assign the response to a variable

      2. Not sure, but I think
      Me!MyPrompt = [Company Name
      should be
      stDocName!MyPrompt = [Company Name

      Use the Tools\Analysis function to list all the field names on the report and look up the inputbox FUNCTION (not the statement) in the help.

      Ralph

Viewing 0 reply threads