Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Runtime Error 13

$
0
0
We use a sql database which keeps a record of all the projects the company is/has been working on. The database has been set up to automatically create a unique, sequential project number for a new project when you either press a button or double click in the blank row at the bottom of the form. All has been working fine for ages but now all of a sudden when we try to automatically create a new project number we are getting a Runtime Error 13 Type Mismatch. The problem is the guy who developed this database no longer works for the company and I don't know anything about visual basic.

Can anyone help me to work out what the problem in the code below is? The line in the code that is highlighted when I click on 'debug' is in bold.

Private Sub Project_ID_DblClick(Cancel As Integer)
Dim strLatestProjID As String
Dim strNewProjectID As String
Dim intID As Integer

Dim con As ADODB.Connection
Dim rst As ADODB.Recordset
Set con = CurrentProject.Connection
Set rst = New ADODB.Recordset

rst.Open "SELECT TOP 1 [Project_ID] FROM [Work Codes] ORDER BY ID DESC", con, adOpenForwardOnly, adLockOptimistic

If Not rst.EOF And Not rst.BOF Then
rst.MoveFirst
strLatestProjID = rst("Project_ID").Value
End If

rst.Close
Set rst = Nothing
Set con = Nothing

If strLatestProjID <> "" Then
strLatestProjID = Right(strLatestProjID, 4)
intID = strLatestProjID + 1
strNewProjectID = "A" & intID
End If

DoCmd.GoToRecord , , acNewRec, 0
Me!Project_ID.Value = strNewProjectID
End Sub

Viewing all articles
Browse latest Browse all 13329

Trending Articles