How do you create a parameterized query in MS Access 2003 and use other queries/forms to fill the parameters and obtain a resultset

前端 未结 5 1860
予麋鹿
予麋鹿 2020-12-04 00:09

I\'d like to be able to create a parameterized query in MS Access 2003 and feed the values of certain form elements to that query and then get the corresponding resultset ba

5条回答
  •  伪装坚强ぢ
    2020-12-04 00:54

    Here is a snippet of code. It updates a table using the parameter txtHospital:

    Set db = CurrentDb
    
    Set qdf = db.QueryDefs("AddHospital")
    qdf.Parameters!txtHospital = Trim(Me.HospName)
    qdf.ReturnsRecords = False
    
    qdf.Execute dbFailOnError
    
    intResult = qdf.RecordsAffected
    

    Here is a sample of the SQL:

    PARAMETERS txtHospital Text(255); 
    
    INSERT INTO tblHospitals ( 
    [Hospital] )
    
    VALUES ( 
    [txtHospital] )
    

提交回复
热议问题