type mismatch error?

mboe

Registered User.
Local time
Today, 20:22
Joined
Dec 27, 2000
Messages
51
I have the following procedure that I am having problems with. I compared it to another procedure that is almost identical and found that tmpAcct# = GSB is giving me trouble. I had GSB as “GSB” since it is text going into a text field using the dim default of variable. If I have the quotes in I get a type mismatch but if I have numbers in quotes instead of GSB (i.e. “2320”) it works fine. If I leave the quotes off the field gets a “0” entered instead of GSB.

Private Sub cmdNewDisbursement_Click()
On Error GoTo Err_cmdNewDisbursement_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim tmpAcct#, tmpLease#, tmpDate, tmpnotes

tmpAcct# = GSB
tmpLease# = Me![lease#]
tmpDate = Date
tmpnotes = Me![last] & ", " & Me![First] & " Lease Payment"


stDocName = "Disbursement"
DoCmd.OpenForm stDocName, , , stLinkCriteria

[Forms]![disbursement]![Acct#] = tmpAcct#
[Forms]![disbursement]![lease#] = tmpLease#
[Forms]![disbursement]![Date] = tmpDate
[Forms]![disbursement]![Notes] = tmpnotes

Exit_cmdNewDisbursement_Click:
Exit Sub

Err_cmdNewDisbursement_Click:
MsgBox Err.Description
Resume Exit_cmdNewDisbursement_Click

End Sub

I checked the table field and that is set as a standard text field. The form Disbursement Acct# field does not have anything in the format control. It makes no sense to me so if someone could help it would be appreciated. Thanks.
 
See if this will work for you....

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Disbursement"
DoCmd.OpenForm stDocName, , , stLinkCriteria

[Forms]![disbursement]![Acct#] = "GSB"
[Forms]![disbursement]![lease#] = Me![lease#]
[Forms]![disbursement]![Date] = Date
[Forms]![disbursement]![Notes] = Me![last] & ", " & Me![First] & " Lease Payment"
 

Users who are viewing this thread

Back
Top Bottom