Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 2nd, 2006, 05:45 PM
Registered User
 
Join Date: Sep 2006
Location: Nampa, ID, USA.
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
__________________
rkellogg
Reply With Quote
  #2 (permalink)  
Old September 4th, 2006, 04:03 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
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
Reply With Quote
  #3 (permalink)  
Old September 6th, 2006, 11:19 PM
Registered User
 
Join Date: Sep 2006
Location: Nampa, ID, USA.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracking who is dropping objects khautinh SQL Server 2000 1 January 10th, 2007 07: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



All times are GMT -4. The time now is 08:39 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.