C
Chris 952
I am an Access novice and any help is greatly appreciated.
In the form I'm creating, I want certain fields to be entered into a table
when a Save button is clicked. If the data has not been saved already, I
want it to create a new record in the table. If the record already exists,
I'd like the record edited with the changes made in the form.
The two fields which identify a record are the Date and the Forecast Group
combination. I've tried to use FindFirst to determine whether a record is
new, but for some reason it doesn't 'find' the date (it has no problem with
the Forecast Group). The formatting in both the form and the table are set
on 'Short Date'. Here is the code:
Set rs = db.OpenRecordset("tbl_Remarks", dbOpenDynaset)
' Determine whether this Date-Forecast Group combination is in the table
rs.FindFirst "[Forecast_GroupID] = " & Me.Forecast_Group & "AND
[Date] = " & Me.Date
If rs.NoMatch Then ' this item has not been added
rs.AddNew
rs!Date = Me.Date
rs!Forecast_GroupID = Me.Forecast_Group
rs!Remarks = Me.Intraday_Event1
rs.Update
Else
rs.Edit
rs!Date = Me.Date
rs!Forecast_GroupID = Me.Forecast_Group
rs!Remarks = Me.Intraday_Event1
rs.Update
End If
If anybody has any ideas as to why the Access isn't reading the Date as
being a match, please let me know.
Thanks.
In the form I'm creating, I want certain fields to be entered into a table
when a Save button is clicked. If the data has not been saved already, I
want it to create a new record in the table. If the record already exists,
I'd like the record edited with the changes made in the form.
The two fields which identify a record are the Date and the Forecast Group
combination. I've tried to use FindFirst to determine whether a record is
new, but for some reason it doesn't 'find' the date (it has no problem with
the Forecast Group). The formatting in both the form and the table are set
on 'Short Date'. Here is the code:
Set rs = db.OpenRecordset("tbl_Remarks", dbOpenDynaset)
' Determine whether this Date-Forecast Group combination is in the table
rs.FindFirst "[Forecast_GroupID] = " & Me.Forecast_Group & "AND
[Date] = " & Me.Date
If rs.NoMatch Then ' this item has not been added
rs.AddNew
rs!Date = Me.Date
rs!Forecast_GroupID = Me.Forecast_Group
rs!Remarks = Me.Intraday_Event1
rs.Update
Else
rs.Edit
rs!Date = Me.Date
rs!Forecast_GroupID = Me.Forecast_Group
rs!Remarks = Me.Intraday_Event1
rs.Update
End If
If anybody has any ideas as to why the Access isn't reading the Date as
being a match, please let me know.
Thanks.