Solved

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

Posted on 2009-04-07
3
219 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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

828 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