Hey there
I'm redesigning a database and want to use some of the same code as the previous one. I'm having a problem with part of the code.
The code is to enter a new record; taking fields from the last record within a table "tblProjectMain" (UGA 001) and creating a record to follow on from this automatically - (UGA 002). (The is a Uganda Project by the way)
Once the user accepts this code from a dialog box the code will open another form to add details. In this forms After insert-event there is code which is this:
Private Sub Form_AfterInsert()
Dim db1 As Database
Dim rsYears As Recordset
Set db1 = CurrentDb
Set rsYears = db1.OpenRecordset("TblProjectMain")
rsYears.AddNew
rsYears![CountryPrefix] = Left(Me.FullCode, 3)
rsYears!
I'm redesigning a database and want to use some of the same code as the previous one. I'm having a problem with part of the code.
The code is to enter a new record; taking fields from the last record within a table "tblProjectMain" (UGA 001) and creating a record to follow on from this automatically - (UGA 002). (The is a Uganda Project by the way)
Once the user accepts this code from a dialog box the code will open another form to add details. In this forms After insert-event there is code which is this:
Private Sub Form_AfterInsert()
Dim db1 As Database
Dim rsYears As Recordset
Set db1 = CurrentDb
Set rsYears = db1.OpenRecordset("TblProjectMain")
rsYears.AddNew
rsYears![CountryPrefix] = Left(Me.FullCode, 3)
rsYears!
Code:
= Mid(Me.FullCode, 7, 3)
rsYears![Suffix] = 1
rsYears.Update
rsYears.Close
db1.Close
End Sub[/COLOR]
I'm kind of just starting out on VBA and I can only assume this creates a record within another table to add the year of the project which would end up like this (UGA 007/1) and can have several years, hence, tblProjectYear. but this table isn't within this code.
I'm getting an "type mismatch" error and it's stopping at the part I've coloured blue?
Does anyone know what might be the problem? I know that a type mismatch would be a datatype mismatch for example but as I'm not sure about the code, perhaps someone could shed some light on this one?
Thanks:confused: