PDA

View Full Version : Don't need "Enter Parameter Value" dialog box



cnsxad
06-27-2008, 09:15 AM
:help I'm not sure that this question really applies to this forum. But I thought I would ask.

I have made a form to run a query using a combo box on the form. When I select the parameter value from the combo box, the "Enter Parameter Value" dialog box pops up. Is there any way to turn this off? I just did it using my fancy combo box which gives me a list and I don't have to type in the value.

I have looked in properties and everywhere else that I can think of to try to turn this dialog box off. Please help me get rid of the this box! Thanks!

cnsxad

CreganTur
06-27-2008, 01:03 PM
Parameter Value windows appear whenever your SQL statement refers to a field that does not exist.

In this case, judging by your post, there is a variable in your SQL statement, the value of which is the selection of your combo box.

When you are using a variable in a SQL statement in VBA, you have to break out the variable in a specific way to get it to work. This depends partially on the DataType of the variable. For the examples below xVar will represent whatever variable you're using.

If the DataType of the variable is a string, then you need to break out the variable like this:
'" & xVar & "'
Just before the variable you need a single quote, then double quote. After the variable you use double quote, then single quote.
Wrapping the variable in single quote marks tells SQL that you are working with a String.

If the variable is a date, then you would use:
#" & xVar & "#
The pound signs tell SQL that your variable is of the Date DataType.

cnsxad
06-28-2008, 12:59 PM
Here is the SQL in my query that I have linked to my form.

PARAMETERS Unit Text ( 255 );
SELECT Stroke.Unit, Stroke.MR, Stroke.GWTG, Stroke.NotStrokeWorkingDx, Stroke.Dx, Stroke.RBDSNotPerformed, Stroke.RBDSscreenNotDateTimed, Stroke.FoodorLiquidgivenpriortoscreen, Stroke.Oralmedgivenpriortoscreenoreval, Stroke.NoOrderforST, Stroke.STSwallowEvalnotperformed, Stroke.[Oralmedgivenafterscreen/eval&madeNPO], Stroke.RN, Stroke.AttendingService, Stroke.Comments
FROM Stroke
WHERE Stroke.Unit=Unit;

I tried inserting the '" & "' around "Stroke.Unit=Unit" and the "Enter Parameters Value" dialog box still appeared.

The command event on my form is simply this.

Private Sub Combo2_AfterUpdate()
DoCmd.OpenQuery "qryUnitDysphagiaScreen", acViewNormal, acEdit
End Sub

Any other suggestions?