Good Morning All,
I have two tables Called Roadway table and Count table.
The composite primary key in the count table being (County+station+stationDirection+Date)
There is a one to many relationship from roadway table to count table on the following fields(county,station,stationdirection,keyno)
I am trying to add a record on the count table through an insert statement with a different Date Through access 2007 vba. Access runs the sql without any error Message, but wont insert the record in the table.
IF there is a record in the count table like(countyx,stationx,stationdirectionL,02/05/2010,keyno)..
I am trying to add a record like((countyx,stationx,stationdirectionL,Todays Date,keyno)
My VBA code to inser the record is is as follows :-
Code:
Private Sub btnOk_Click()
Dim x As String
Dim strsql2 As String
Dim strsql As String
Dim db As Database
Set db = CurrentDb()
strsql = "INSERT INTO [Count table] ( Co, [Station#], [Station Direction], CTDate, keyno )"
strsql2 = strsql & " VALUES('" & Me.County & "','" & Me.Station & "','" & Me.[Station Direction] & "',#" & Me.NewDate & "#,'" & Me.keyno & "');"
MsgBox (strsql2)
db.Execute strsql2
MsgBox ("Record inserted")
End Sub
Any help is greatly appreciated. I am unable to attach the screen shots. Will figure it out and post.
Regards,
Chaitanya