vba - Getting an error when trying to use the Controls() function on an access form -
i'm trying build sql insert statement several form control values in access.
i've read use controls() function dynamically reference controls.
i've tried this:
private sub insertcoeff(byval prov string, byval region string) dim strsql string dim insertsql string dim valuessql string insertsql = "insert 'coefficient de fermage'" valuessql = "(" valuessql = valuessql & "('1f','2f')" valuessql = valuessql & ",('" & me.controls(prov & region & "lbl") & "','" & me.controls(prov & region & "lbl") & "')" valuessql = valuessql & ",('" & me.controls(prov & "lbl") & "','" & me.controls(prov & "lbl") & "')" valuessql = valuessql & ",('" & me.controls(prov & region & "terres") & "','" & me.controls(prov & "bat") & "')" valuessql = valuessql & ",('" & me.dateeff & "','" & me.dateeff & "')" valuessql = valuessql & ")" strsql = insertsql & " values " & valuessql end sub
but runtime error 438 (object doesn't support property or method) though vba auto-suggests controls() method when start typing "me."
any idea why fails?
i referencing labels, correct syntax is
valuessql = valuessql & ",('" & me.controls(prov & region & "lbl").caption & "','" & me.controls(prov & region & "lbl").caption & "')"
Comments
Post a Comment