this may be difficult to explain

Mrs.Meeker

Registered User.
Local time
Today, 22:38
Joined
Mar 28, 2003
Messages
172
I have a series of forms that open on click of various buttons. On frmProjectMasterDetail there are two buttons "QC" and "QA", when either of these buttons open a new form opens: frmUser2 which displays the survey type either "QC" or "QA". My problem starts when you click the "Next" button. Only the "QC" survey opens because I can't figure out how to include the two choices.

Here's the code that I have.


Private Sub cmdNextStepGen_Click()
On Error GoTo Err_cmdNextStepGen_Click
DoCmd.SetWarnings False

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "qryGenerateQC"
DoCmd.OpenQuery stDocName, acNormal, acEdit

stDocName = "frmSurveyQCHeader"

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

DoCmd.Close acForm, "frmuser2"
DoCmd.Close acForm, "frmprojectMasterdetail"
Exit_cmdNextStepGen_Click:
Exit Sub

Err_cmdNextStepGen_Click:
MsgBox Err.Description
Resume Exit_cmdNextStepGen_Click

End Sub

The other survey has the same name with QA substituted for QC.

thanks, I'm lost!
Rhonda
 
You need OpenArgs, search the Access help and the forum on the OpenArgs part of the Docmd.openform command....

Regards

The Mailman
 
Tony: "Generate QC" is an append query. I didn't write this code, it was written by a guy from my IT department. He is not available to help me at this time. I don't understand much about code yet, but I'm trying! I have two different surveys and there are two queries as well. Each to open the different survey. (?)

Namliam: I will look into the OpenArgs as you have suggested. Perhaps it will enlighten me.

I have alot of issues with this database and hope to correct them one by one. As I said above, I got started with this with a great deal of help from a guy in IT but he is very very busy and I hate to keep asking him for help.
 
You might also find it easier to have one query rather than two and pass the parameters to it
 
Hi Rich!

If I want to have only one query, I have a "user type" which has a "b" and "d"

...for query generate QC the criteria is "b" or "d" and for query generate QA the criteria is "b". Hate to sound like an idiot but hey... :) How do I write my criteria?

Gee I have a lot to learn!
 
In simple terms just put [Enter Type] in the criteria section for the field, it's actually better to use a form to enter the parameters, but try that first
 
Rich, I don't understand. The query uses "b" and "d" to select specific questions to show on the survey. One survey (QC) uses all the questions (b & d) and the other (QA) shows only the questions labeled b.

I tried the [Enter Type] and get Enter Parament Value messages and then it wants to append 0 rows.

Not good.
 
It would be easier if you posted an example here in 97ver for us to have a look at
 
I'm sorry, it was created in 2000. It is also too large. I've been trying to remove stuff but haven't managed to make it small enough. I don't want to remove too much for fear that it won't make any sense.

I'm still trying to reduce its size...
 
Following up Rich's thoughts - you could have a parameter box in the query that could say [Enter type or leave blank for all types]

Then you could have B and D (together) - or just B - or just D

Col
 
I've been playing around with this. Is this something that the user would have to fill out? I just want the form to open after they select their choice of QC or QA from another form. They wouldn't know what these codes mean.

When the database opens to the main menu there is a choice to either view projects or previously taken surveys. When the view projects button is selected another form opens where they can select the project that the survey will be taken on. Then another form opens that shows the details of that project. On that form is where they select whether they will do the QC or QA survey. Once they make that choice another form opens where they fill in their name, office, etc. This form shows whether they have selected QC or QA. Finally when they select the next button the survey opens. Either for QC or QA. Unfortunately only the QC form is opening for either choice.
 
Just change the criteria to reference the form ie
Forms!SomeForm!YourField
 
Thank you Rich!!! Now that I have it limited to one query, I still have the trouble of it always opening the QC survey regardless of which button is selected. How can I change my code to correct it. I have tried entering an if statement with laughable results. (I got both forms to open at once!

I do have an idea tho...I'll let you know
 
Wooo Hooo!! It worked!!

Now that I have one qryGenerateQC my if statement worked! Thanks Chris! You're Number One!!!

Private Sub cmdNextStepGen_Click()
On Error GoTo Err_cmdNextStepGen_Click
DoCmd.SetWarnings False

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "qryGenerateQC"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If survey_type = "QC" Then
stDocName = "frmSurveyQCHeader"
stLinkCriteria = "[tbluser2.SurveyNumber]=" & Me![SurveyNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stDocName = "frmSurveyQAHeader"
stLinkCriteria = "[tbluser2.SurveyNumber]=" & Me![SurveyNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

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

DoCmd.Close acForm, "frmuser2"
DoCmd.Close acForm, "frmprojectMasterdetail"
Exit_cmdNextStepGen_Click:
Exit Sub

Err_cmdNextStepGen_Click:
MsgBox Err.Description
Resume Exit_cmdNextStepGen_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom