简体   繁体   中英

Getting current selected record value in access subform

I have 2 subforms in access 2010 database; Based on selection of subform1 field value , the vba program will run the subform2 output which common text fields in subform 1 and 2 as "supplier_name". So, I tried the "on double click" event on subform1 to write the currentRecord method see below,

Private Sub Supplier_name_DblClick(Cancel As Integer)
    strSQL = "Select * from [Query1] where"
    strSQL = strSQL & "[Supplier_name] ="'" & "Me!current record![Supplier_name]" &"'"
    Form![Mainform]![Subform2].Form.RecordSource = strSQL
End Sub

I am getting Run-time error 3075 at the 2nd line; Syntax error (missing operator) in query expression '[Supplier_name] =Me!current record![Supplier_name]' Please help

You are missing a space after the where in the second row of your code:

strSQL = "Select * from [Query1] where "

and there is also a problem with your " and ' chars in the third line:

strSQL = strSQL & "[Supplier_name] ='" & Me!current record![Supplier_name] & "'"

谢谢它为我工作,但没有currentrecord属性

strSQL = strSQL & "[Supplier_name] ='" & Me![Supplier_name] & "'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM