I suspect this is a simple syntax problem, but I'm stuck.
I have this function:
function CreateSPT (SPTQueryName string, as the SQLString string, as in the form of _ConnectString string) as the dim mydatabase database , myquerydef as QueryDef, MyRS record set as mydatabase = DBEngine.Workspaces (0) .Databases (0) set myquerydef = mydatabase.CreateQueryDef (SPTQueryName) myquerydef.Connect = ConnectString myquerydef.SQL = SQLString myquerydef.ReturnsRecords = wrong myquerydef.ReturnsRecords = True set MyRS = myquerydef.OpenRecordset () 'MyRS.MoveFirst DoCmd.OpenQuery SPTQueryName, acViewNormal, acReadOnly myquerydef.Close end function
a button called my form Interpretation is pressed on.
Private Sub Btn_Search_Click () If not IsNull (DLookup ("[AccessionNumber]", "[SA2001]", "[AccessionNumber] = '& [Farm] [SA2001] [ Txt_LabEpNo] & amp ;! " '")) and found' MsgBox "" 'fills the form as required' I dirty as removed from the code and the "MsgBox" not found "Me.Refresh dim SPTQueryName string as in as dim SQLString string dim ConnectString string DoCmd.Close acQuery, "XQuery" DoCmd.DeleteObject acQuery, "XQuery" SPTQueryName = "XQuery" SQLString = "HospitalNumber, SQLUser.EP_VisitNumber as former name .EpVIS_GivenName, as the nickname SQLUser.EP_VisitN umber.EPVIS_Surname, SQLUser.EP_VisitNumber.EPVIS_DateOfBirth birth date, select SQLUser.EP_VisitNumber.EPVIS_DebtorNumber_DR as as SQLUser.EP_VisitNumber.EPVIS_DoctorCode_DR- & gt; CTDR_Surname as Cannes, as SQLUser.EP_VisitNumber.EPVIS_VisitNumber SampleReceivedDate, SQLUser.EP_VisitTestSet.VISTS_TestSet_DR- & gt as AccessionNumber, SQLUser.EP_VisitNumber.EPVIS_DateOfCollection; CTTS_Department_DR- & gt; LabDept as a CTDEP_NAME from SQLUser.EP_VisitTestSet, where is the SQLUser.EP_VisitNumber (SQLUser.EP_VisitTestSet.VISTS_ParRef = SQLUser.EP_VisitNumber.EPVIS_VisitNumber) and (SQLUser.EP_VisitTestS et.VISTS_ParRef = '1500000000') "ConnectString =" ODBC; DSN = DSNNAME; Server = IPADDRESS; Port = 1972; Database = DatabaseName; Authentication method = 0; UID = USERNAME; PWD = Password; Static cursor = 0; QUERY TIMEOUT = 0; Unicode SQLTES = 0 "Calls CSTT (SPTCNN, SQL String, ConnectString)" me. [Hospital number] = RE ("hospital number") m. Refresh m [hospital number] = null m [hospital number] = myrse (" Hospital number ") End if and end
My problem is that I can not populate the result of the pass-through query
Basically, I How do I declare records? [Hospital number] = MyRs ("hospital number") does not work as "myrse" function is not defined.
< Div class = "after" text "itemprop =" text ">
How do you keep in mind these two statements should work together:
myquerydef .ReturnsRecords = False set MyRS = Myquerydef.OpenRecordset ()
You should have a query that records returns, then open a record set, then Drag the value from the record set.
You declare MyRs in another function. You should have something like this:
MyRs = somequery.OpenRecordset () me! [Hospital number] Price = MyRs! Hospital number Value
No comments:
Post a Comment