How to .GoToRecord on another form

I have a search form (frmMailingSearch) that displays a grid of rows that is 
a subset of the entire table.  From that grid, the user may give focus to 
the selector box of one row, and then click the Select button.  I would then 
like to show the row in the detail form, by going directly to it.  The 
detail form may or may not have been instantiated as yet.  I want the detail 
form to always have it's recordsource as the full underlying table, not just 
the one row that we "goto".



The DoCmd.GoToRecord is not working as I want, because "MailingID" is not 
actually an offset value, it's the key value of the row.  Should I be using 
a different cmd or structuring the offset value differently?  This code is 
in the frmMailingSearch.cmdSelect_Click event.



   Dim frm As Form

   Dim booFormFound As Boolean

   booFormFound = False

   For Each frm In Forms

      If frm.Name = "frmMailing" Then

         booFormFound = True

         Exit For

      End If

   Next frm

   If booFormFound = True Then

      DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID

   Else

      DoCmd.OpenForm "frmMailing", acNormal

      DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID

   End If



I have also substituted .FindRecord for .GoToRecord, with passing syntax, 
but no resultset.  Any better ideas would be appreciated.



Thanks in advance,

Dean S


0
Dean
9/25/2007 12:54:20 AM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
2768 Views

Similar Articles

[PageSpeed] 12

Since you only want to do this once, you could do it in the OnLoad or OnOpen 
events. With your DoCmd.OpenForm - supply the ID in the OpenArgs attribute.

In your form's Onload or OnOpen event use a RecordsetClone and Findfirst() 
to locate the bookmark of the record matching the ID in Me.OpenArgs then set 
the form's recordset bookmark to the one found in the clone.

'Call form and set to ID 1
DoCmd.OpenForm "myForm",,,,,,1

Private Sub Form_Open()
    ' Find the record that matches OpenArgs
    Dim rs As Recordset

    Set rs = Me.RecordsetClone
    rs.FindFirst "[myID] = " & Me.OpenArgs)
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Steve

"Dean Slindee" wrote:

> I have a search form (frmMailingSearch) that displays a grid of rows that is 
> a subset of the entire table.  From that grid, the user may give focus to 
> the selector box of one row, and then click the Select button.  I would then 
> like to show the row in the detail form, by going directly to it.  The 
> detail form may or may not have been instantiated as yet.  I want the detail 
> form to always have it's recordsource as the full underlying table, not just 
> the one row that we "goto".
> 
> 
> 
> The DoCmd.GoToRecord is not working as I want, because "MailingID" is not 
> actually an offset value, it's the key value of the row.  Should I be using 
> a different cmd or structuring the offset value differently?  This code is 
> in the frmMailingSearch.cmdSelect_Click event.
> 
> 
> 
>    Dim frm As Form
> 
>    Dim booFormFound As Boolean
> 
>    booFormFound = False
> 
>    For Each frm In Forms
> 
>       If frm.Name = "frmMailing" Then
> 
>          booFormFound = True
> 
>          Exit For
> 
>       End If
> 
>    Next frm
> 
>    If booFormFound = True Then
> 
>       DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID
> 
>    Else
> 
>       DoCmd.OpenForm "frmMailing", acNormal
> 
>       DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID
> 
>    End If
> 
> 
> 
> I have also substituted .FindRecord for .GoToRecord, with passing syntax, 
> but no resultset.  Any better ideas would be appreciated.
> 
> 
> 
> Thanks in advance,
> 
> Dean S
> 
> 
> 
0
Utf
9/25/2007 2:22:03 AM
Thanks for the tip.  Here's the final code that works great!

      DoCmd.OpenForm "frmMailing", , , , , , MailingID

Private Sub Form_Load()

    If Not IsNull(Me.OpenArgs) Then

       'find the record that matches OpenArgs

       Dim rs As ADODB.Recordset

       Set rs = Me.RecordsetClone

       rs.Find "MailingID = " & Me.OpenArgs

       If Not rs.EOF Then

          Me.Bookmark = rs.Bookmark

       End If

    End If

End Sub


"SteveM" <SteveM@discussions.microsoft.com> wrote in message 
news:B8C62BA6-F74B-4B83-97AC-0A0D9EBF9B15@microsoft.com...
> Since you only want to do this once, you could do it in the OnLoad or 
> OnOpen
> events. With your DoCmd.OpenForm - supply the ID in the OpenArgs 
> attribute.
>
> In your form's Onload or OnOpen event use a RecordsetClone and Findfirst()
> to locate the bookmark of the record matching the ID in Me.OpenArgs then 
> set
> the form's recordset bookmark to the one found in the clone.
>
> 'Call form and set to ID 1
> DoCmd.OpenForm "myForm",,,,,,1
>
> Private Sub Form_Open()
>    ' Find the record that matches OpenArgs
>    Dim rs As Recordset
>
>    Set rs = Me.RecordsetClone
>    rs.FindFirst "[myID] = " & Me.OpenArgs)
>    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> End Sub
>
> Steve
>
> "Dean Slindee" wrote:
>
>> I have a search form (frmMailingSearch) that displays a grid of rows that 
>> is
>> a subset of the entire table.  From that grid, the user may give focus to
>> the selector box of one row, and then click the Select button.  I would 
>> then
>> like to show the row in the detail form, by going directly to it.  The
>> detail form may or may not have been instantiated as yet.  I want the 
>> detail
>> form to always have it's recordsource as the full underlying table, not 
>> just
>> the one row that we "goto".
>>
>>
>>
>> The DoCmd.GoToRecord is not working as I want, because "MailingID" is not
>> actually an offset value, it's the key value of the row.  Should I be 
>> using
>> a different cmd or structuring the offset value differently?  This code 
>> is
>> in the frmMailingSearch.cmdSelect_Click event.
>>
>>
>>
>>    Dim frm As Form
>>
>>    Dim booFormFound As Boolean
>>
>>    booFormFound = False
>>
>>    For Each frm In Forms
>>
>>       If frm.Name = "frmMailing" Then
>>
>>          booFormFound = True
>>
>>          Exit For
>>
>>       End If
>>
>>    Next frm
>>
>>    If booFormFound = True Then
>>
>>       DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID
>>
>>    Else
>>
>>       DoCmd.OpenForm "frmMailing", acNormal
>>
>>       DoCmd.GoToRecord acDataForm, "frmMailing", acGoTo, MailingID
>>
>>    End If
>>
>>
>>
>> I have also substituted .FindRecord for .GoToRecord, with passing syntax,
>> but no resultset.  Any better ideas would be appreciated.
>>
>>
>>
>> Thanks in advance,
>>
>> Dean S
>>
>>
>> 


0
Dean
9/27/2007 5:23:26 PM
Reply:

Similar Artilces:

Custom Form (no code) & OL2002 SP3
Microsoft states in KB article 331788 that if you create a custom form and upgrade to Office SP3 that custom forms with no vbs should appear in the preview pane vice getting the "This item contains active content that cannot be displayed in the preview pane..." Unfortunately, I have 2002 SP3 installed, I can create a form with no code and still no joy on the preview pane! Is there something else that needs to be checked? Anything else anyone can think of that would kill it? The KB states this applies to SP1 - if upgrade to SP3 from std 2002 (non-SP1) does this matter? Can't ...

How to fill a combo box with choice from another combo box
I am trying to fill combo box with a choice made in another combo box. I am trying to select a choice from a combo box "Customer_11" and then have the following choices available in another combo box "State_11". Below is the code I was trying to use, but not having any luck with getting it to work. '===================================================== 'CES Customer Information With Me.Customer_11 .AddItem "Customer 1" .AddItem "Customer 2" .AddItem "Customer 3" ...

one or two emails will not go through form same user to same recei
Exchnage 2003 We have strange issue. some time we will not receive emails from client and most time we will. same email can be sent without any modification in subject or content and it will go through. what can cause this? Any suggestion will be helpful. thanks Chad You will need to enable message tracking and SMTP logging. Identify a time when the user said he sent you a message that you did not receive. Run message tracking to see if it's being delivered to the desination MB. If it doesn't show, check your SMTP logs to see if there are any SMTP transactions occuring with them d...

Change and refresh OLEObject showing Excel chart on Access form.
(Sorry this is not strictly Excel charting but I have had no hints in the Access groups where I posted this first - hoping someone in the Excel world can help me) Hi All I display an Excel chart in a MS Acess User form using an unbound OLE object. I am trying to change the Excel workbook(and therefore chart) that my OLEObject displays: Private Sub Form_Load() With Me.oleExcelChart ' SourceDoc is currently "W:\Public\83.xls" Debug.Print .SourceDoc .SourceDoc = "W:\Public\XX.xls" Debug.Print .SourceDoc ' ## how can I get ...

Article on showing Windows style error on MS Access Form
I am building an application with several forms. In the BeforeUpdate event for the form, I will run some data validation routines. If there is an error, I would like to display an error control next to each field containing an error (the exclamation point). The user can then hover over the error control and get an explanation of the error. This is similar to how a normal windows application works. Some time ago, I can recall seeing an article that described the exact technique that I want to use, but I can't find it now. Could someone please point me to the article? Many thanks! ...

Creating/ modifying custom Real Estate Listing Form in Outlook 2000
I've downloaded a Real Estate Listing form created for Outlook 98 into my Outlook 2000. I'm looking for a manual on how to modify this form to service my business needs. Anyone have a suggestion where I can learn how to do this? ...

2003 Form fields losing formatting in 2007
Hi there, I have some forms, created in Word 2003, which when opened as a .docx, all form fields revert to Times New Roman font but if they are opened as a .doc, they are in the correct font of Arial. Anyone got any ideas why and how I can fix this? Thanks very much. This doesn't make any sense. Documents always open in the format in which they are saved. What *exactly* are you doing? -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com ...

Form to display current month's targets?
We have a welcome form on our system that displays the current month's target enquiries and bookings figures. At present those figures are entered manually at the start of each month, but I would like to store all the year's figures in a table month by month and then have the system automatically pull the appropriate numbers when the month changes. I'm fine with the table design, but how do I tell the form to check the current date and then display the relevant figures? (Or would it be best to use a query to do this?) Many thanks CW CW, Several ways to do ...

How to have one year value added to another cell
I have a cell where I date foramtted fill in the date. How to have on another cell the date + one year automatically filled? So, A1 02-04-06 auto: B1 02-04-07 Bart Excel 2003 =DATE(YEAR(A1)+1,MONTH(A1),DAY(A1)) Bob Umlas Excel MVP "AA Arens" <bartvandongen@gmail.com> wrote in message news:1164983094.802613.212520@l12g2000cwl.googlegroups.com... > I have a cell where I date foramtted fill in the date. > How to have on another cell the date + one year automatically filled? > > So, > > A1 02-04-06 > > auto: > B1 02-04-07 > > > Bart >...

recovery of DB to another servers SG?
Is it possible to recover a mailbox database to another Exchange servers recovery storage group from the same org? I highly doubt it, but my boss wants me to confirm. Thanks. Yes, as long as they are in the same administrative group. -- Ben Winzenz Exchange MVP MessageOne Read my blog! http://winzenz.blogspot.com http://feeds.feedburner.com/winzenz (RSS Feed) "BigHaig" <BigHAig@aol.com> wrote in message news:tufYf.314$Fy2.264@newsread3.news.pas.earthlink.net... > Is it possible to recover a mailbox database to another Exchange servers > recovery storage grou...

Sell at One Location, Deliver from Another Location
For a multi-store retailer, is there any way in RMS to sell a product at one location, then deliver it from another one? For example, say a retailer has two stores, which includes two Store Operations licenses (one at each store) along with Headquarters. A sale is made at store 1, but the product is only in stock at the store 2. Is there a way in RMS (with HQ) to sell the product at store 1 but deliver it to the customer at store 2? I realize that this can be done via a stock transfer (to move the product from store 2 to store 1 after the fact), but this requires an additional manua...

Is there a way to import another priv1.edb, priv1.stm
My Domain controller took a bad crash and want to know if there is a way to import my old .edb or .stm databases for exchange? I didn't have a chance to export them before it took a dive Please help http://www.ontrack.com/powercontrols/ -- Neil Hobson Exchange MVP For Exchange news, links and tips, check: http://www.msexchangeblog.com "Exchange 1" <anonymous@discussions.microsoft.com> wrote in message news:2559801c46052$ec0d0ec0$a501280a@phx.gbl... > My Domain controller took a bad crash and want to know if > there is a way to import my old .edb or .stm dat...

how do you keep a column in date form
i'm making a spreedsheet in office excel, in column A I have a list of dates. I would type in 4/5 for an date and excel would automatic change the date to 4-Apr. I like this way, but when I got to cell 26, the change will not happen. I type in 4/5 and I get just the number 1 in the cell, for the rest of the cells down, can someone help me. Copy the cell that has the format you like and paste format it to the cells that you want to have the date format. "s2m2" <s2m2@discussions.microsoft.com> wrote in message news:F350F90F-24B9-4B79-BE39-20AB0414015D@microsoft.com......

Printing a single form which has tabs
Hello I have created a form in which I am inputting survey data. There are 5 tab pages in this form. I want to print all 5 tabbed pages. I want to create a button called "Print Record". When one clicks on this button, I want it to print all 5 pages. At the moment, I print one page. Then tab to the second page and print, and so. Can I set it so that one you click on print, you can decide on which page you want to print or print all five pages? Can I do this in code? If this isn't the right section, please direct me. Thank you in advance. Generally spea...

Customize Task Details Form
Not sure if this is possible. Can I customize the Task Details Form? I'd like to add some more input fields to it. My company has 23 (way too many) columns they'd like to have all schedules populate. I've added the necessary columns to the Gantt view but I dislike tabbing across and not being able to see all the data at once. I figured out how to create a customized entry form but I'd like to display it in the bottom pane of a split view and I can't figure that out. It would be even better if I could start with the default task entry form and modify it...

Set form field on double click
I am using MS Access 2003. I have a continuous form that is run off of a query "srbScientific Review". The query's criteria is set to [Enter Last Name] in the LastName field. That part works fine. I get my continuous form that shows LastName, DocID, and Title of Document. I would like to double click on the DocID and have the following happen: 1. Open another form "publications" 2. Set the SRBId field to the DocId field that I double clicked on. PLEASE help. I think I need to bookmark, clone.... I'm very confused. As a kick in the right ...

Microsoft Form 2.0 Controls in VC causing error
My application developed using VC++6.0 in W2K running well in my development PC (with Visual Studio 6.0 installed). When I run the same application in a client PC without VS installed, I get this error: An unsupported operation was attempted. At last I found out it is caused by the 'Microsoft Form 2.0 commandbutton' and 'Microsoft Form 2.0 Label'. After I removed these controls the application run fine. I have registered the file FM20.dll using Regsvr32 and it show succeeded. May someone help how can I make those controls run well in my client PC? Thanks. ...

Add ability to print W-2 C forms in Great Plains
The W-2 C forms require both previously reported and corrected information to print. Great Plains should add the ability to store this information and print these forms. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Communi...

My code stops after the record saves....form never closes
Users are going into to update a number, and they want to close the form before the record gets saved, thus losing their changes. I created an Exit button, which should save the record change and close the form. Here's the code: If Me.Dirty Then RunCommand acCmdSaveRecord End If Forms![frmRMSHours]![Act Hours] = Me![Text9] DoCmd.Close If the record is dirty, they press Exit and the record saves. They have to press Exit again and the form closes. If the record is not dirty, the form will close when pressing Exit. What am I doing wrong? To save ...

Move forms in public folders 5.5 to exchange 2003
Hello all, I recently migrated from exchange 5.5 to exchange 2003 using ADC and things were fine. I later deleted ADC and moved Exchange 2003 to native mode. I recently found out that the public folders have not been migrated. I earler used the pfmigrate script in exchange 2003. For some reason it had just created blank folders with no data on it. Now i want to migrate/transfer the public folders content(like forms) from exchange 5.5 to exchange 2003 computer. Please help. Best, Karthik ...

transferring macros from one PC to Another
Hi, I have some macros on one PC. The machine is very slow and I want to format it. But I want to transfer all my macros to a CD or another PC. Please help me in doing that. Tell me how can I do it. Thanks Much Suman Suman, to move to another computer you can export a macro and save it, to do this from your workbook, right-click the workbook's icon and pick View Code. This icon is to the left of the "File" menu this will open the VBA editor, click on the module you want to save and go to file and export file, then save it to a CD or what ever you backup to, then import it to the...

Uploading Form Problem
FP 2003 / win xp / URL of form is : http://www.icingpictures.co.uk/online_order_form.htm Just set up a form and am trying to get it to work - got the following error message... Form Validation Error Please correct the information you provided by following these steps, then submit the information again: * A FrontPage File Upload component is incorrectly configured. Please set the MIME encoding type for the form to be multipart/form-data. Return to the form. I do not usually have problem spublishing - server does have frontpagr extensions - i have tried to look in t...

order enty form
help here is my problem i have a db that tracks orders and i need a form to enter the order number and part number and quantirty. i will need to enter allot of orders at one time so i want to use a comtinuous form to enter the info into the orders table what i want to do is enter the job # and the part number and auto fill the discription and size. i have a part numbert tabel with fields part number, discription size there are too many to use a combo box. i have an order table with fileds job number, part number , discription , qantity, start time end tine, efficentcy, total time , down time, ...

Database will not work on another pc?
I have a database (with some VBA modules) that I gave to someone else to look at. The databse works fine on my pc and I have installed in on three other boxes and they all worked fine. His pc, for some reason, first give a "Compile error" when he starts to run the application. I think asked him to look at the module (to see if I could help him debug) and he gets a message that says the module is locked? Plus under tools the references is grayed out? Anyone have any ideas whay this would happen on a certain pc? All of the pc's are running XP. It is a 2003 database running ...

change inbox default form
how do i change the default form for inbox in outlook 2002 sp3? Tools-Forms-Design a form. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Peter Fuller asked: | how do i change the default form for inbox in outlook 2002 sp3? You can make a registry change to substitute your custom form for the default form. See http://www.outlookcode.com/d/newdefaultform.htm#ch...