Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Finding value in Form Load event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul3rd - 27 Sep 2007 15:05 GMT
Hello, I have an Access form with a MSCAL control [ApptCal] and
a combo box control [cboApptDate].
The underlying table "ApptDis" has as it's primary key a Date/Time
field "ApptDate".
I have code in place that synchronizes the (cboApptDate] & [ApptCal]
and uses the Bookmark property to synchronize [ApptCal] & table records.
That code is:
Private Sub ApptCal_AfterUpdate()
Me.RecordsetClone.FindFirst "[ApptDate] = #" & Me![ApptCal] & "#"
   With Me.RecordsetClone
   .FindFirst "[ApptDate] = #" & Me![ApptCal] & "#"
       If Not .NoMatch Then
           Me.Bookmark = .Bookmark
       End If
   End With
End Sub

I'm trying to write code that will Load the form onto the record that
reflects the current Date. Such as:

Private Sub Form_Load()
Dim rst As Object
Dim strCriteria As String

strCriteria = "[ApptDate] = #" & Me![ApptCal] & "#"

Set rst = Me.Recordset.Clone
rst.FindFirst strCriteria

If Not rst.EOF Then
   Me.Bookmark = rst.Bookmark
End If
End Sub

I believe my problem is in the strCriteria line, not defining the value(?)
Any help would be greatly appreciated
Paul
Douglas J. Steele - 27 Sep 2007 15:32 GMT
Does strCriteria get a value in the Load event?

Try putting MsgBox strCriteria after you define it to see.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hello, I have an Access form with a MSCAL control [ApptCal] and
> a combo box control [cboApptDate].
[quoted text clipped - 33 lines]
> Any help would be greatly appreciated
> Paul
Paul3rd - 27 Sep 2007 15:51 GMT
Yes, I get #9/25/2007# as a value, which is the date of the first record in
the table.

> Does strCriteria get a value in the Load event?
>
[quoted text clipped - 37 lines]
> > Any help would be greatly appreciated
> > Paul
Paul3rd - 27 Sep 2007 18:15 GMT
I replaced the refrence to the [ApptCal] control in the strCriteria line with
Date.
I also replaced Set rst = Me.Recordset.Clone with Set rst = Me.Recordsetclone
Everything works correctly now.
Thank You very much for your input.
Paul

> Does strCriteria get a value in the Load event?
>
[quoted text clipped - 37 lines]
> > Any help would be greatly appreciated
> > Paul
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.