taking code from txtbox/lstbox and inserting into record set.

Tommy888

Registered User.
Local time
Today, 23:13
Joined
Nov 9, 2008
Messages
12
Code:
Option Compare Database

Private Sub btnNewRace_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("tbl_Race", dbOpenDynaset)

rs.AddNew
!RaceName = Me.txt_RaceName
!Season = Me.lst_Season
!SchemeID = Me.lst_SchemeID
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub

Im having an issue with this code, it says
An identifier beginning with a period is valid only within a With block. This error has the following cause and solution:


  • The identifier begins with a period. Complete the qualification of the identifier or remove the period..
Any ideas what I have to do to solve this?
 
Two choices here:
Code:
rs.AddNew
rs!RaceName = Me.txt_RaceName
rs!Season = Me.lst_Season
rs!SchemeID = Me.lst_SchemeID
rs.Update
rs.Close
...or
Code:
With rs
   .AddNew
   !RaceName = Me.txt_RaceName
   !Season = Me.lst_Season
   !SchemeID = Me.lst_SchemeID
   .Update
   .Close
End With
 
Thanks that works correctly now ;).
 

Users who are viewing this thread

Back
Top Bottom