I assume this will be easy for you guys!

piedpiper

Registered User.
Local time
Yesterday, 19:32
Joined
Aug 5, 2009
Messages
42
I need to open a form if they click on a button called "next" if the condition is they have selected "yes" from a radio button. If they have clicked "no" then after clicking the "next" button it would open a different form

Click yes = form1
Click no = form2

In both situation I need to close the current form while opening a new one based on the seletion.

Here is the code I have now...as you guessed it's not working

Private Sub Command1_Click()
If Me.Frame77 = True Then
DoCmd.OpenForm "s6_Form6"
End If
If Me.Frame77 = False Then
DoCmd.OpenForm "s9_Form9"
End If

End Sub
 
The frame doesn't do True and False. You need to check for the index value assigned to your options.

So for example:

Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 0
      DoCmd.OpenForm "s6_Form6"
   Case 1
      DoCmd.OpenForm "s9_Form9"
End Select
End Sub
 
Oh, and I would name your controls something MEANINGFUL instead of leaving them at

Command1

or

Frame77

as it will help you (six months down the road) and anyone else who comes along after you to know right by looking at them what they are. As they stand, nobody would know what they are or what they are used for on first glance.
 
Thank you so much...that worked like a charm...anyway to tell the code to close the form while opening the new one?

The frame doesn't do True and False. You need to check for the index value assigned to your options.

So for example:

Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6"
   Case 2
      DoCmd.OpenForm "s9_Form9"
End Select
End Sub
 
Thank you so much...that worked like a charm...anyway to tell the code to close the form while opening the new one?


Just add this (EXACTLY as shown, do not revise anything) to the code, just below the End Select part

DoCmd.Close acForm, Me.Name, acSaveNo
 
New problem... with this skip pattern - everything is working ok. except that when it skips it does not continue on the last record (current record) it continues from a previous record so after the skip the fields are already populated from previous entries.

With non skip buttons in design view I put the following action "GoToRecord" and in arguments ",,Last,"

Anyway to incorporate that into the code?

Just add this (EXACTLY as shown, do not revise anything) to the code, just below the End Select part

DoCmd.Close acForm, Me.Name, acSaveNo
 
Do you mean you want the form being opened to go to a new record? If so, perhaps the easiest thing is to put this in each form's ON LOAD event:

Code:
If Not Me.NewRecord Then
   DoCmd.RunCommand acCmdRecordsGoToNew
End If
 
When I start with form 1 it creates a new record... so in the same row in the main database the columns populate...but with this new skip pattern it does not continue on the same row, it will find the previous row and show me the responses from there. It should continue in the same row. Regardless of previous entries.
This is easy without the skip pattern as I said before, I configure ALL the "next" buttons that jump from one form to the next form to include the aforementioned setting


Do you mean you want the form being opened to go to a new record? If so, perhaps the easiest thing is to put this in each form's ON LOAD event:

Code:
If Not Me.NewRecord Then
   DoCmd.RunCommand acCmdRecordsGoToNew
End If
 
When I start with form 1 it creates a new record... so in the same row in the main database the columns populate...but with this new skip pattern it does not continue on the same row, it will find the previous row and show me the responses from there. It should continue in the same row. Regardless of previous entries.
This is easy without the skip pattern as I said before, I configure ALL the "next" buttons that jump from one form to the next form to include the aforementioned setting

I guess I'm not understanding what you mean by "skip pattern." What is it you want the form that is being opened to actually open to? What are these forms bound to? Are they bound to the same table as the previous form that is being closed?
 
I guess I'm not understanding what you mean by "skip pattern." What is it you want the form that is being opened to actually open to? What are these forms bound to? Are they bound to the same table as the previous form that is being closed?

Yes, there is only one table, all other forms populate that table and it works as I said... from form to form the data is colleted in the same row, your yes/no code changed that, it no loger populates on the same row, it will will populate in a previous row, a previous record i guess. I wish I can send you the file so you can take a look and see for your self..I'm having a hard time explain this.
 

Attachments

Yes, there is only one table, all other forms populate that table and it works as I said... from form to form the data is colleted in the same row, your yes/no code changed that, it no loger populates on the same row, it will will populate in a previous row, a previous record i guess. I wish I can send you the file so you can take a look and see for your self..I'm having a hard time explain this.

Okay, I can't take a look until I get home, which will be in about 10 hours from now (have an Access Users Group meeting right after work). But, remove the code I put in there for moving to a new record. I misunderstood what you needed. You actually needed to use something like this:
Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6", acNormal, ,"[PKFieldName]=" & Me!PKField
   Case 2
      DoCmd.OpenForm "s9_Form9", acNormal, ,"[PKFieldName]=" & Me!PKField
End Select
End Sub
 
Sorry I'm such a noob...

Now I get error Acces cannot find field 'pkfied'.

What did I do wrong?


Okay, I can't take a look until I get home, which will be in about 10 hours from now (have an Access Users Group meeting right after work). But, remove the code I put in there for moving to a new record. I misunderstood what you needed. You actually needed to use something like this:
Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6", acNormal, ,"[PKFieldName]=" & Me!PKField
   Case 2
      DoCmd.OpenForm "s9_Form9", acNormal, ,"[PKFieldName]=" & Me!PKField
End Select
End Sub
 
You need to figure out which control houses the primary key field you have on the form that is closing and then you need to also have that field in the recordset of the form(s) that are being opened.

The part "[PrimaryKeyFieldHere] = " is the name of the primary key field that YOU have on your form that is being OPENED.

The part Me!PrimaryKeyFieldHere is the name of the primary key field that YOU have on your CLOSING form.

You have to supply the actual field/control names from your database. I just used bogus names as an example.
 
Thank you so much boblarson!!!!

I get an error now, but I'm sure it's just a small problem that's easy to fix...?

Does anyone else have a solution? I would like to wrap this up asap, as I can present to my boss today. I attached the file. pls take a look - All I'm trying to do is populate data on a row to row basis.

Thank you so much everyone!!!!
 

Attachments

Hi, A lot of us can't look at 2007 files, could you convert to access 2003?
 
Sorry again...should of figured that one out :(

At the begining of the datatable there is a column called ID...there is also a field called "Remedy_Ticket" - wonder if I use those?


You need to figure out which control houses the primary key field you have on the form that is closing and then you need to also have that field in the recordset of the form(s) that are being opened.

The part "[PrimaryKeyFieldHere] = " is the name of the primary key field that YOU have on your form that is being OPENED.

The part Me!PrimaryKeyFieldHere is the name of the primary key field that YOU have on your CLOSING form.

You have to supply the actual field/control names from your database. I just used bogus names as an example.
 
If you are using the same table for each then it SHOULD be:

Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6", acNormal, ,"[COLOR="red"][ID]=" & Me!ID[/COLOR]
   Case 2
      DoCmd.OpenForm "s9_Form9", acNormal, ,[COLOR="Red"]"[ID]=" & Me!ID[/COLOR]
End Select
End Sub
 
If you are using the same table for each then it SHOULD be:

Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6", acNormal, ,"[COLOR=red][ID]=" & Me!ID[/COLOR]
   Case 2
      DoCmd.OpenForm "s9_Form9", acNormal, ,[COLOR=red]"[ID]=" & Me!ID[/COLOR]
End Select
End Sub

That did it!!!! thank you so much...everything is work now!!!! ty ty ty :)
 
If you are using the same table for each then it SHOULD be:

Code:
Private Sub Command1_Click()
Select Case Me.Frame77
   Case 1
      DoCmd.OpenForm "s6_Form6", acNormal, ,"[COLOR=red][ID]=" & Me!ID[/COLOR]
   Case 2
      DoCmd.OpenForm "s9_Form9", acNormal, ,[COLOR=red]"[ID]=" & Me!ID[/COLOR]
End Select
End Sub

You no what would be cool - if at the end of the questionnaire before the click end to start a new record... If I can post all their responsense so they can verify their entries and go back if they made errors if not submit and then restart... is this some thing easy to do?
 

Users who are viewing this thread

Back
Top Bottom