Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch - Access '97

Status
Not open for further replies.

regava

Programmer
May 24, 2001
152
US
When I execute this subroutine, I get the message "Type Mismatch" pointing to the first line after the DoCmd statement, WHAT AM I DOING WRONG? I am trying to read the table Tatno, stored the values locally and then update one of the fields (tatnumber) and close the table.
NOTE: The table named Tatno has two fileds only as follows:
tatyear as TEXT 4 characters long
tatnumber as long numeric
---------------------------------------------------------------------------------------------------
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click

Dim strYear As Variant
Dim lngNumber As Long
Dim strNumber As String

DoCmd.OpenTable "Tatno", acViewNormal, acEdit

lngNumber = [Tatno]![tatnumber]
strYear = [Tatno]![tatyear]

[Tatno]![tatnumber] = [Tatno]![tatnumber] + 1
DoCmd.Close acTable, "Tatno", acSavePrompt
strNumber = Right(Str(lngNumber), 5)
[Tatno] = strYear + strNumber + " "

MsgBox "The TAT No. for this Petitons is: " + _
"(" + [Level] + ")" + strYear + "-" + _
strNumber + " (" + Left([Tax], 2) + ")"

[Record_Date] = Date
DoCmd.GoToRecord , , acNewRec

Exit_Add_Record_Click:
Exit Sub

Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click

End Sub
---------------------------------------------------------------------------------------------------
 
Regava:

Is it you intention to find the last record number used, increment it by one and then add that as a new record?

If so, I think there is a better way to approach the problem. Let me know if you want me to show you another way.

With your given code, the problem may be lngNumber. Try dimensioning it as an Integer rather than as a Long.


Larry De Laruelle
larry1de@yahoo.com

 
Larry thank you for your help. What I am trying to do is use a number that is stored in the table "tatno" to assign it as a case number in a tracking system and then update it to be assigned to the next case in the future. This subroutine is in the Add_Record command button, which will save the information entered in this form, including the number obtained from the table "tatno" in the tracking record itself. Any help is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top