Problem with Bookmark Procedure.

G

Guest

Hello,
I have a problem with the Bookmark procedure on a form ("Appt") with a
calendar control.
The date field is a combobox[cboStartDate] which opens to todays date or on
click
displays a calendar control from which the user selects a date, that value
is then
passed to [cboStartDate].
That procedure works fine, I would like to add a Bookmark procedure so the
appropriate record is selected when the user updates the [cboStartDate].
I've added the following code but no event is triggered, I do not get an
error message.

Private Sub cboStartDate_AfterUpdate()
Me.RecordsetClone.FindFirst "[EventsID] = " & Me![cboStartDate]
'EventsID is the primary key field in the underlying query.

Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

I've also changed the primary key field to a Date/Time column in the
underlying
table (and changed Bookmark argument) but that made no difference.
Any help would be greatly appreciated.
Paul3rd
 
G

Guest

First, since it is a date type field, it needs the correct delimiters in the
FindFirst:
Me.RecordsetClone.FindFirst "[EventsID] = #" & Me![cboStartDate] & "#"

Next, I would flesh this out a bit:

With Me.RecordsetClone
.FindFirst "[EventsID] = #" & Me![cboStartDate] & "#"
If Not .NoMatch Then
Me.BookMark = .BookMark
End If
End With
 
G

Guest

Thank you for the input, I used your code but it didn't work UNTIL I placed
it in the
AfterUpdate event for the Calendar control. It seems that the event couldn't
be triggered unless it was done specifically from the control/event that
updated the [cboStartDate]. This is the code I entered:

Private Sub ocxCalendar_AfterUpdate()
Me.RecordsetClone.FindFirst "[StartDate] = #" & Me![ocxCalendar] & "#"
'StartDate is a field in the underlying table that is updated by cboStartDate.
With Me.RecordsetClone
.FindFirst "[StartDate] = #" & Me![ocxCalendar] & "#"
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End Sub

Again, Thanks very much for your help.
Paul3rd


Klatuu said:
First, since it is a date type field, it needs the correct delimiters in the
FindFirst:
Me.RecordsetClone.FindFirst "[EventsID] = #" & Me![cboStartDate] & "#"

Next, I would flesh this out a bit:

With Me.RecordsetClone
.FindFirst "[EventsID] = #" & Me![cboStartDate] & "#"
If Not .NoMatch Then
Me.BookMark = .BookMark
End If
End With
--
Dave Hargis, Microsoft Access MVP


Paul3rd said:
Hello,
I have a problem with the Bookmark procedure on a form ("Appt") with a
calendar control.
The date field is a combobox[cboStartDate] which opens to todays date or on
click
displays a calendar control from which the user selects a date, that value
is then
passed to [cboStartDate].
That procedure works fine, I would like to add a Bookmark procedure so the
appropriate record is selected when the user updates the [cboStartDate].
I've added the following code but no event is triggered, I do not get an
error message.

Private Sub cboStartDate_AfterUpdate()
Me.RecordsetClone.FindFirst "[EventsID] = " & Me![cboStartDate]
'EventsID is the primary key field in the underlying query.

Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

I've also changed the primary key field to a Date/Time column in the
underlying
table (and changed Bookmark argument) but that made no difference.
Any help would be greatly appreciated.
Paul3rd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top