Solved

Open form to current record, but then cann't change record

Posted on 2009-04-07
3
221 Views
Last Modified: 2013-11-27
I have a button that opens a for to the current record, unless there is no record at which point is opens the form in add mode:

If IsNull(Me.BorrowerInquiryID) Then
    DoCmd.OpenForm "frmPasswords", acNormal, , , acFormAdd

Else
    DoCmd.OpenForm "frmPasswords", , , "[BorrowerInquiryID]= " & Me.BorrowerInquiryID & ""

This works fine; however, on frmPasswords I have a combo box that allows the user to chose another "borrower's inquiry."  When I open the form directly from the navigation pane, the combo box works find; when I open the from with the button as programmed above, the combo box does not go to the selected record:

    DoCmd.SearchForRecord , "", acFirst, "[VHDABorrowerInquiryID] = " & Str(Nz(Screen.ActiveControl, 0))

What can I do to my button's code so it does not lock the frmPassword to one record?

Thanks!
0
Comment
Question by:Phereklos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24092735

If IsNull(Me.BorrowerInquiryID) Then
    DoCmd.OpenForm "frmPasswords", acNormal, , , acFormAdd

Else

'this part of the code is limiting the records in frmPasswords to one

    DoCmd.OpenForm "frmPasswords", , , "[BorrowerInquiryID]= " & Me.BorrowerInquiryID & ""

end if


use this codes instead

If IsNull(Me.BorrowerInquiryID) Then
    DoCmd.OpenForm "frmPasswords", acNormal, , , acFormAdd

Else

'this part of the code is limiting the records in frmPasswords to one

    DoCmd.OpenForm "frmPasswords", Openargs:= Me.BorrowerInquiryID
end if

' NOW in the load event of frmPasswords place this codes

private sub form_load()

if len(me.openargs)>0 then
  with me.recordsetclone
      .findfirst "[BorrowerInquiryID]= " & Me.Openargs

      if not .nomatch then
           me.bookmark=.bookmark
           else
             msgbox "Record not found"
      end if
  end with

end if

end sub
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 24092738
use this codes instead

If IsNull(Me.BorrowerInquiryID) Then
    DoCmd.OpenForm "frmPasswords", acNormal, , , acFormAdd

Else

    DoCmd.OpenForm "frmPasswords", Openargs:= Me.BorrowerInquiryID
end if



' NOW in the load event of frmPasswords place this codes

private sub form_load()

if len(me.openargs)>0 then
  with me.recordsetclone
      .findfirst "[BorrowerInquiryID]= " & Me.Openargs

      if not .nomatch then
           me.bookmark=.bookmark
           else
             msgbox "Record not found"
      end if
  end with

end if

end sub
0
 

Author Closing Comment

by:Phereklos
ID: 31567805
Thank you.  I will read up on openargs - haven't used that yet.  Appreciate your help.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question