Solved

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

Posted on 2009-04-07
3
208 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 119

Expert Comment

by:Rey Obrero
Comment Utility

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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
Thank you.  I will read up on openargs - haven't used that yet.  Appreciate your help.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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 the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now