Declaring a Variable

G

Guest

Hi all,
Sorry, this one seems like it should be easy, but I cannot figure it out...
I am wanting to capture an amount when a specific check box is selected -
similar to how if you are using a query and place the [] around some title in
the criteria section, that will be the header for collecting information for
a field. I would like to do this in VB and used the following:
If ShortPayment.Value = -1 Then
Dim PayAmount As String
PayAmount = [Amount Short?]
Special_Note.Value = "LETTER SENT - ORDER ON HOLD - waiting for payment
of " + PayAmount
ElseIf ShortPayment.Value = 0 Then
Special_Note.Value = "ORDER ON HOLD: In Return Drawer"
End If
I am getting a runtime error of 2465 that it cannot find the field. I would
like an entry box (similar to the one that happens with a query or a report)
pop up, allow the user to put in a value, hit ok, then fill in the amount
into the Special_Note value.
Any help is always appreciated! Thanks!
-gary
 
A

AccessVandal via AccessMonster.com

Hi Gary,

You have "Dim" PayAmount as a string. Access is looking for a field because
you have used the square brackets. When you use a square brackets, it means
that it is an object or it is referance the Form's RecordSource property. As
in "Select [Amount Short?] From Table1". or the Form's control named "Amount
Short?".

To correctly use a "Dim" as a String, use the double qoute like....

PayAmount = "[Amount Short?]"
and as tina posted.

PayAmount = InputBox("[Amount Short?]")
Gary Dolliver wrote:
Hi all,
Sorry, this one seems like it should be easy, but I cannot figure it out...
I am wanting to capture an amount when a specific check box is selected -
similar to how if you are using a query and place the [] around some title in
the criteria section, that will be the header for collecting information for
a field. I would like to do this in VB and used the following:
If ShortPayment.Value = -1 Then
Dim PayAmount As String
PayAmount = [Amount Short?]
Special_Note.Value = "LETTER SENT - ORDER ON HOLD - waiting for payment
of " + PayAmount
ElseIf ShortPayment.Value = 0 Then
Special_Note.Value = "ORDER ON HOLD: In Return Drawer"
End If
I am getting a runtime error of 2465 that it cannot find the field. I would
like an entry box (similar to the one that happens with a query or a report)
pop up, allow the user to put in a value, hit ok, then fill in the amount
into the Special_Note value.
Any help is always appreciated! Thanks!
-gary
 
G

Guest

Thank you both!

AccessVandal via AccessMonster.com said:
Hi Gary,

You have "Dim" PayAmount as a string. Access is looking for a field because
you have used the square brackets. When you use a square brackets, it means
that it is an object or it is referance the Form's RecordSource property. As
in "Select [Amount Short?] From Table1". or the Form's control named "Amount
Short?".

To correctly use a "Dim" as a String, use the double qoute like....

PayAmount = "[Amount Short?]"
and as tina posted.

PayAmount = InputBox("[Amount Short?]")
Gary Dolliver wrote:
Hi all,
Sorry, this one seems like it should be easy, but I cannot figure it out...
I am wanting to capture an amount when a specific check box is selected -
similar to how if you are using a query and place the [] around some title in
the criteria section, that will be the header for collecting information for
a field. I would like to do this in VB and used the following:
If ShortPayment.Value = -1 Then
Dim PayAmount As String
PayAmount = [Amount Short?]
Special_Note.Value = "LETTER SENT - ORDER ON HOLD - waiting for payment
of " + PayAmount
ElseIf ShortPayment.Value = 0 Then
Special_Note.Value = "ORDER ON HOLD: In Return Drawer"
End If
I am getting a runtime error of 2465 that it cannot find the field. I would
like an entry box (similar to the one that happens with a query or a report)
pop up, allow the user to put in a value, hit ok, then fill in the amount
into the Special_Note value.
Any help is always appreciated! Thanks!
-gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top