how to pass multiple openargs
Posted on 2008-01-30
i have an order form that i want to search to narrow down on retrieved records, basically i have a search form, which has a text box (txtSearchKey) and 2 combo boxes (cboSearchCriteria and cboStatus) the text box will be used as the value to search on, cbosearchcriteria is used to define what to search through and cbostatus is what status the order is in to search. so for instance if i wanted to search for order number 17 and i know it is live, i would type - 17 (in the text box) select "order id" (from cbosearchcriteria) and select "live" (from cbostatus).......i then have a few variables to hold the selections, strSearchKey, strSearchCriteria and strStatus.....these will get the values from the objects and i want to pass all three through to the order form as openargs.....when these are recieved at the orderform i want to use them in an sql statement to change the recordsource of the object.....something that will do the following (sorry, im new to sql so this may be wrong):
Me.RecordSource = "SELECT tblOrder.*, tblOrder.CustomerID, tblOrder.OrderStatus FROM tblOrder WHERE (((strcriteria)=strsearchkey) AND ((tblOrder.OrderStatus)=strstatus));"
as you can see, the first where statement is saying, locate the searchkey based on the search criteria so strcriteria would be "orderid" and strsearchkey would be "17" after the AND statement the order status would be "Live"....
i am using the following code to send the open args:
DoCmd.OpenForm strDocName, acNormal, , , , acDialog, strSearchKey & ";" & strCriteria & ";" & strStatus
and the following to recieve open args in the open form event of the order form:
strSearchKey = Left(OpenArgs, InStr(OpenArgs, ";") - 1)
strCriteria = Mid(OpenArgs, InStr(OpenArgs, ";") + 1)
strStatus = right(OpenArgs, InStr(OpenArgs, ";") + 2)
the above code doesnt work very well at all, i have tested it with text boxes to see what i am recieving through the openargs, and i am getting, the search key fine, then the text box that should just recieve the strcriteria is getting "orderid;live" insetad of just "orderid" and the last text box is getting ";live" instead of just "live"
help please! im tearing ma hair out