General discussion


Access VBA coding problem

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 Sub

MsgBox Err.Description
Resume Exit_Command159_Click

End Sub

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

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

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.


Related Discussions

Related Forums