Easy Question

  • Thread starter Thread starter MIKEB
  • Start date Start date
M

MIKEB

I have 21 form that I created and now I owuld like to have
them all coincide with each other. What i mean is, I would
like to put a button on each form that allows the user to
go right to the next form, and so on. Now would I have to
put in a complex code within each form? If so what kind of
code, a string? Please respond. thanks
 
Well, the easiest way to do as you suggest is to use the
command button wizard.

Open the first form in Design View. Be sure you've placed
a form control with your key field as its source on the
form. Change the Visible property to No (on the Format
tab) if you don't want your user to see and/or access the
key field.

Show the Toolbox toobar if it's not visible, click on the
Command Button icon, and place a button on your form.
Follow the instructions of the wizard, choosing Form
Operations, Open Form, etc. The wizard will then create
an event procedure for the OnClick event of the command
button that opens your next form showing the current
record.

HTH
Kevin Sprinkel
 
Be sure that your key field is present (visible or not) on
each form you intend to open. To close all forms
conveniently when you're done, see Dirk Goldgar's response
in yesterday's thread on this topic.

HTH
Kevin Sprinkel
 
Put this code behind each button

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form name"

stLinkCriteria = "[RecordID]=" & "'" & Me![RecordID] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Jim
 
Jim that code was great help but i have a few more
questions. Now when you say recordID, Does tha mean put
the form name in where record ID is? Becuase when i do
that, i get flagged because it says access can not find
that particular feild. One more question will this code
allow me to jump from one feild to the next feild as it is
now saved or do I have to write another code to tell it
how to jump from table to table? Thanks Again
Mike
-----Original Message-----
Put this code behind each button

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form name"

stLinkCriteria = "[RecordID]=" & "'" & Me![RecordID] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

Jim
-----Original Message-----
I have 21 form that I created and now I owuld like to have
them all coincide with each other. What i mean is, I would
like to put a button on each form that allows the user to
go right to the next form, and so on. Now would I have to
put in a complex code within each form? If so what kind of
code, a string? Please respond. thanks
.
.
 
Kevin,
I did as you said to do but my form keeps dissapearing
when I am doing as you said. I put the command button in,
Use the wizard to create it but when I go to use it, it
will either A)Not show the original form or B)Ask me to
put in a value number. What am I doing wrong because all I
want this button do to is sit at the end of the form and
when I push it opens up the form saved after it. Thanks.
Mike
 
Mike,

It's not clear to me what the problem might be, but I have
some suggestions. First, verify that the code behind your
command button looks something like this, with the
following replacements:

CmdOpenNextForm
the name of the command button (under the Other tab)

frmForm2
the name of the form you'd like to open

[KeyID]
the field in the next form that contains the key field
you'll match on

Me![KeyID]
the name of the key field control in the current form

If your code does not look like this, cut, paste, and edit
it into your form and try again.

Check the first form also to see if it's set to Modal and
Popup = "Yes". This would prevent the second form from
showing if its two properties are set to No (the default).

Thinking outside the box, if these forms are all based on
the same table, but are separated for clarity or process,
you might consider a single tabbed form, which requires no
code at all to maneuver between pages.

If none of this works, post your table structure(s) and
the names and record sources of your forms, and I'll try
again.

Good luck. And remember "you've got to climb the mountain
if you want to enjoy the view". :^)

Private Sub CmdOpenNextForm_Click()
On Error GoTo Err_CmdOpenNextForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmForm2"

stLinkCriteria = "[KeyID]=" & Me![KeyID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CmdOpenNextForm_Click:
Exit Sub

Err_CmdOpenNextForm_Click:
MsgBox Err.Description
Resume Exit_CmdOpenNextForm_Click

End Sub
 
Back
Top