Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2006, 05:45 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Tracking My mileage

I would like to track my milage.

Table
MilageId - Autonumber Primary Key
RepId - Number
Milage_Date
Milage_Start_Time
Milage_Start_Milage
Milage_Stop_Time
Milage_Stop_Milage

I have a from for start milage and a form for Stop milage. I would like to be able to have the stopMilage form lookup on the table to see if there is a record with this date and RepId and add the current information to the same record. If nothing is present (I forgot to start my milage for the day) just add a new record.

I have been trying to write some code in vb. This is what I have so far.
Private Sub Combo7_AfterUpdate()

Dim strSQL As String
Dim lngKey As Long

lngKey = Nz(DLookup("milageid", "milage", "RepID = " & Me.Combo7 & " AND [Milage_Date] = #" & DATE & "#"), 0)


If lngKey <> 0 Then
Me.Undo
Me.RecordsetClone.FindFirst "[milageId] = " & lngKey
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Sub

I get an error on the last line
Me.Bookmark = Me.Recordsetclone.Bookmark
It says no record set. The line just above it has the correct value for the lngKey but I don't know how to get the book mark feature to work correctly.

Any help would be appreciated.
Rkellogg
 
Old September 4th, 2006, 04:03 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I might not have this right, but here goes: Recordset clone returns a recordset. It is not a thing to be manipulated. I think this is what you need:
Code:
Private Sub Combo7_AfterUpdate()

    Dim strSQL As String
    Dim lngKey As Long
    Dim tmpRs  As Recordset

    Set tmpRs = Me.RecordsetClone

    lngKey = Nz(DLookup("milageid", _
                        "milage", _
                        "RepID = " & Me.Combo7 & _
                        " AND Milage_Date = #" & DATE & "#"), _
                0)

    If lngKey <> 0 Then
        Me.Undo
        tmpRs.FindFirst "milageId = " & lngKey
        Me.Bookmark = tmpRs.RecordsetClone.Bookmark
    End If

End Sub
 
Old September 6th, 2006, 11:19 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am still getting the error in the same place... on the last line with me.bookmark = tmpRs.recordsetClone.bookmark

Can't seem to get it to work.

rkellogg





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracking who is dropping objects khautinh SQL Server 2000 1 January 10th, 2007 08:19 PM
Tracking who is changing what? rrhandle SQL Server 2000 1 August 15th, 2006 03:03 AM
Tracking Users arimakidd Classic ASP Professional 0 August 17th, 2005 05:35 PM
UPS Tracking jafarsalam XML 0 October 20th, 2004 04:23 PM
SESSION tracking natmaster Beginning PHP 1 August 18th, 2003 01:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.