Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Field Value

Status
Not open for further replies.

JoeyArr

IS-IT--Management
Nov 16, 2005
13
US
Trying to pass my projectID field to my next form in sequence. But the following form seems to write a new record.

I have it set up with a switchboard for mainly navigation purposes. The users will navigate through forms according to the request (logo, writing, event and such) On the main form users enter general info about the request and then they have options to navigate to the next form based on the request type. Each request type has a command button for an option taking the user to the next form. But when I enter data in the main form and then move to a request type it simply starts a new record.

I have tried setting the value of the projectID on the request type forms to = the value of the projectID on the main form but no luck.

the projectID field is autonumber could this be the problem? Also I found that it is impossible to search on the autonumber field.

Thanks.
 
I'm assuming that you're using DoCmd.OpenForm to open your second form. If that's the case, you can pass the projectID field as the last parameter of your call to DoCmd.OpenForm...

Code:
DoCmd.OpenForm "Form2", , , , , , txtProjectID.Value

Good Luck!
 
My Code for the command button:
Dim frm As Form
Set frm = Forms!frmLogo
frm.Recordset.FindFirst "[ID]=" & Me!ID
DoCmd.Close acForm, "frmnewgeninfo2"
End Sub

They are linking now but the second form(frmLogo) is trying to over-write the projectID that is auto-numbered in the first(frmnewgeninfo2).

 
How are ya JoeyArr . . .

JoeyArr said:
[blue] But when I enter data in the main form and then move to a request type it simply starts a new record.[/blue]
[blue]What do you intend to happen?[/blue]

[blue]BTW: Welcome to Tek-Tips![/blue]

Calvin.gif
See Ya! . . . . . .
 
I simply want to link the forms so that the request type form(frmLogo) will continue writing to that record with the logo type, logo size and so forth without the projectID field being over-written.

I forgot to mention that all of my forms are linked to the same table.

 
This sounds like the exact same problem I am having. TheAceMan1 suggested for me to check out this Faq FAQ702-5860 , and while it was helpful for what I wanted I would like it to open the form without me having to enter the RecordID...I want that process automated.
 
JoeyArr . . .
JoeyArr said:
[blue]I simply want to link the forms so that [purple]the request type form(frmLogo) will continue writing to that record[/purple] . . .[/blue]
I believe I understand what your after.

Two big problems here:
[ol][li]More than one form [blue]writing to the same record[/blue] is sure to raise an error.[/li]
[li]Since the record in the mainform is not saved yet (uncommited), passing the projectID to the newly opened form is of no consequence as [purple]you can't find or relate that which is not yet commited![/purple][/li][/ol]
So in the button on the [blue]mainform[/blue] you need:
Code:
[blue]   DoCmd.RunCommand acCmdSaveRecord [green]'Commit the record![/green]
   DoCmd.OpenForm "[purple][b]FormName[/b][/purple]"[/blue]
Then in the Load event of the opened form:
Code:
[blue]   Me.Recordset.FindFirst "[ProjectID] = [red][b]'[/b][/red]" & Forms![purple][b]MainFormName[/b][/purple]!ProjectID & "[red][b]'[/b][/red]"[/blue]
If ProjectID is numeric, remove the single quotes in [red]red[/red].

[blue]Your thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
I am now getting an error that Access cannot find the 'Me' macro.
 
JoeyArr . . .

Your putting the code on the event line instead of putting it in the event routine! Delete the code where you put it and lets start over . . .
[ol][li]First we need to set an option, so from the menubar click [blue]Tools[/blue] - [blue]Options[/blue] - [blue]Forms/Reports Tab[/blue].[/li]
[li]On the bottom left you'll see [blue]Always use event procedures[/blue]. Put a check in the box and click OK.[/li][/ol]
[ol][li]Now navigate your way to the [blue]Click[/blue] event of the button on the mainform and put the cursor on the event line.[/li]
[li]Click the 3 elipses
Elipses.BMP
just to the right.[/li]
[li][purple]You are now looking at the routine for the click event![/purple] It is here you paste the code![/li]
[li]Pasting the code I gave earlier you should have:
Code:
[blue]Private Sub [purple][b]ButtonName[/b][/purple]_Click()
   DoCmd.RunCommand acCmdSaveRecord [green]'Commit the record![/green]
   DoCmd.OpenForm "[purple][b]FormName[/b][/purple]"
End Sub[/blue]
[/li]
[li]Save the code.[/li]
[li]To return to form design view, [blue]File[/blue] - [blue]Close and Return to Microsoft Access[/blue].[/li][/ol]
I'll leave the [blue]Load[/blue] event of the [blue]opened form[/blue] to you! . . .




Calvin.gif
See Ya! . . . . . .
 
I appreciate the effort and I did everything exactly as you stated, but it is still not linking.

I enter data into the main form then click on the click event to go to the next form and it writes to a totally new record.

Thanks for your help
 
JoeyArr . . .

Did you complete the instructions for the [blue]Load[/blue] event of the form your opening!

If so . . . post the code . . .

Calvin.gif
See Ya! . . . . . .
 
Me.Recordset.FindFirst "[ProjectID] = " & Forms!frmnewgeninfo2!ProjectID & ""

is in the On Load event of the form.
 
Roger That JoeyArr . . .

I seem to be missing something here, so going back to your post origination:
JoeyArr said:
[blue][purple]Trying to pass my projectID field to my next form in sequence[/purple]. But the following form seems to write a new record.[/blue]
Lets say you get projectID passed to the next form . . . [blue]what are you expecting to happen next?[/blue]

Calvin.gif
See Ya! . . . . . .
 
I simply want to continue writing to that record.

I have a large table and the records are rather large as well.

Say I have general info being logged from the first form then I have a command button linking to another form which will contine writing to the record that I started with the general information form. The projectID being autonumber and unique.

 
Ok JoeyArr . . .

Earlier in this thread you said:
JoeyArr said:
[blue]I enter data into the main form then [green]click on the click event[/green] to go to the next form and [purple]it writes to a totally new record.[/purple][/blue]
[green](I hope you meant click on the button!)[/green]

If your making a new record instead, this is indicitive that [blue]projectID[/blue] is not the primarykey of the table. If this is correct what field is the primarykey and what is its data type?

When you open the 2nd form (no editing yet) the same primarykey record you edited in the mainform should be the same record showing (depending on how you have the 2nd form setup) . . . available for editing.

[blue]Your Thoughts![/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Yes I click on the Click button, and the projectID is the primary key for the main table, which all other forms are linked to as well. Its datatype is autonumber. And the 2nd form is available for editing (data entry).
 
JoeyArr . . .

If you have the [blue]Data Entry[/blue] property of the 2nd form set to [blue]Yes[/blue] . . . set it to [blue]No[/blue] and try again . . .

Calvin.gif
See Ya! . . . . . .
 
I know this is not my thread, but I have been using it for my database. I set up my main form and my form that opens through the button like it has been suggested in this thread. The records are opening as they should...except for any records that were created after I attempted to remove the forms as subforms. When I open any of those records the 2nd form opens as the first record. If I attempt to create a record the 2nd form is record 1. What am I doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top