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 / Forms Programming / February 2007

Tip: Looking for answers? Try searching our database.

Move record selector

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Can - 26 Feb 2007 18:49 GMT
I have a continuous subform (modal pop-up) in a database.  I want to copy
some of the fields into a temporary table.  As the user does data entry they
are in the last record in the subform.  I want to move the record selector to
the top but the code I have has been tempermental.  Any ideas?

Here's the two versions of code I've tried:

VERSION 1

Dim dbs As Database
Set dbs = CurrentDb
       
Dim rstSubform As DAO.Recordset
Dim rstCurrent As Recordset

       Set rstCurrent = dbs.OpenRecordset("_Current_Location", dbOpenDynaset)
               
       tmpValue = "No"
       rstCurrent.MoveFirst

       Dim lng As Integer
       lng = 0
       Set rstSubform = Me!zzzAdd_Location_Tanks_Split.Form.RecordsetClone

       If rstSubform.RecordCount > 0 Then
           rstSubform.MoveFirst
           Do While lng < Me!zzzAdd_Location_Tanks_Split.Form.SelTop And
Not rstSubform.EOF
               rstCurrent.AddNew
               rstCurrent![_Current_Location_Location_ID] = Location_ID.Value
               rstCurrent![_Current_Location_To_Tank_ID] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_To_Tank_ID]
               rstCurrent![_Current_Location_From_Tank_ID] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_From_Tank_ID]
               rstCurrent![_Current_Location_TotalMales] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalMales]
               rstCurrent![_Current_Location_TotalFemales] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalFemales]
               rstCurrent![_Current_Location_TotalUnknown] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalUnknown]
               rstCurrent.Update
               rstSubform.MoveNext
               lng = lng + 1
           Loop
       End If

       Set rstSubform = Nothing
       rstCurrent.Close

VERSION 2

Dim dbs As Database
Set dbs = CurrentDb
       
Dim rstSubform As DAO.Recordset
Dim rstCurrent As Recordset

       Set rstCurrent = dbs.OpenRecordset("_Current_Location", dbOpenDynaset)
               
       tmpValue = "No"
       rstCurrent.MoveFirst

       Set rstSubform = Me!zzzAdd_Location_Tanks_Split.Form.RecordsetClone

       rstSubform.MoveFirst

       Do Until rstSubform.EOF
           rstCurrent.AddNew
           rstCurrent![_Current_Location_Location_ID] = Location_ID.Value
           rstCurrent![_Current_Location_To_Tank_ID] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_To_Tank_ID]
          rstCurrent![_Current_Location_From_Tank_ID] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_From_Tank_ID]
           rstCurrent![_Current_Location_TotalMales] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalMales]
           rstCurrent![_Current_Location_TotalFemales] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalFemales]
           rstCurrent![_Current_Location_TotalUnknown] =
Forms![Add_Location_Split]![zzzAdd_Location_Tanks_Split]![Location_Tanks_TotalUnknown]
           rstCurrent.Update
           If (rstSubform.RecordCount = rstSubform.AbsolutePosition + 1) Then
               Exit Do
           Else
               rstSubform.AbsolutePosition = rstSubform.AbsolutePosition + 1
           End If
       Loop

       Set rstSubform = Nothing
       rstCurrent.Close
Damon Heron - 26 Feb 2007 20:52 GMT
Not sure, but you may be able to use Stephen Lebans code to move the
scrollbar back to the top (the first record) without an API call.
Here is a sample db for you to look at.
http://www.lebans.com/setgetsb.htm

HTH
Damon

> I have a continuous subform (modal pop-up) in a database.  I want to copy
> some of the fields into a temporary table.  As the user does data entry
[quoted text clipped - 92 lines]
>        Set rstSubform = Nothing
>        rstCurrent.Close
 
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.