[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

access open another db & form on last record

I have a button on my switchboard that opens  a second database.  I would like the second database to open on a paticular form & the last record of the form.  Here is the query for opening the second db:

Private Sub Command54_Click()
Dim strDB As String, appAccess As Access.Application
    strPath = "\\Fileserver\is_data\Documentation\IT-Private\Scheduling DB\WIP\3-25-10 WIP\"
    strDB = strPath & "Schedulingdb_ShipSplitBatch.accdb"
    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strDB
    appAccess.Visible = True
    appAccess.UserControl = True '
End Sub

Any suggestions?
0
johnmadigan
Asked:
johnmadigan
  • 2
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
Private Sub Command54_Click()
Dim strDB As String, appAccess As Access.Application
    strPath = "\\Fileserver\is_data\Documentation\IT-Private\Scheduling DB\WIP\3-25-10 WIP\"
    strDB = strPath & "Schedulingdb_ShipSplitBatch.accdb"
    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strDB
    appAccess.Visible = True
    appAccess.UserControl = True '

   appAccess.docmd.openform "formX" ' add this line  
End Sub
0
 
iandianCommented:
if your table on which the form is based has a field, e.g. named "date", with the date of creation for a record you can add this to reverse the order (get the last record)

appAccess.Forms.Item("FormX").OrderBy("date DESC")

the same can be done with an autonumber field, e.g named "ID"

appAccess.Forms.Item("FormX").OrderBy("ID DESC")
0
 
Rey Obrero (Capricorn1)Commented:
Private Sub Command54_Click()
Dim strDB As String, appAccess As Access.Application
    strPath = "\\Fileserver\is_data\Documentation\IT-Private\Scheduling DB\WIP\3-25-10 WIP\"
    strDB = strPath & "Schedulingdb_ShipSplitBatch.accdb"
    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strDB
    appAccess.Visible = True
    appAccess.UserControl = True '

   appAccess.docmd.openform "formX" ' add this line  s
   appAccess.docmd.gotorecord,,aclast
End Sub
0
 
iandianCommented:
ah yeah my bad, that would be easier.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now