Hi there
I am totally beginner in Access, just trying to learn myself during my free time
I am using unbound form, to update the record, but I am unable to update the record, as when i try to run the codes, Access giving me following error
The form, first pull the customer details from list box and based on clicking the record, filled the empty fields on the form (which works perfectly), but when i change the details, I am getting following error
Need help from Gurus of Access
Run-time error '2185':
You can't reference a property or method for a control unless the control has the focus
List box code (which work perfectly)
Private Sub Updatecustomerbillto_AfterUpdate()
txtcustomerid = Updatecustomerbillto.Column(0)
txtcustomername = Updatecustomerbillto.Column(1)
txtcontactperson = Updatecustomerbillto.Column(2)
txtaddressline1 = Updatecustomerbillto.Column(3)
txtaddressline2 = Updatecustomerbillto.Column(4)
txtaddressline3 = Updatecustomerbillto.Column(5)
txtaddresscity = Updatecustomerbillto.Column(6)
txtaddressprovince = Updatecustomerbillto.Column(7)
txtaddresspostalcode = Updatecustomerbillto.Column(8)
txtaddresscountry = Updatecustomerbillto.Column(9)
txttelephonenumber = Updatecustomerbillto.Column(10)
txtfaxnumber = Updatecustomerbillto.Column(11)
End Sub
Following are the code when i press the update button (to update the information in the table "Custbillingdetail" - when i click the debug button, following red area is highlighted with Yellow and last line marked as error
Private Sub Cmdupdatecustomerbillto_Click()
Dim dbs As DAO.Database, sql As String, rCount As Integer
txtcustomerid.SetFocus
If txtcustomerid = "" Then
MsgBox "Please select a record to update"
End If
Set dbs = CurrentDb
sql = "UPDATE Custbillingdetail Set Customer_Name=" & txtcustomername.Text _
& ",Contact_Person=" & txtcontactperson.Text & ",Address_line1=" & txtaddressline1.Text _
& ",Address_line2=" & txtaddressline2.Text & ",Address_line2=" & txtaddressline3.Text _
& ",Address_city=" & txtaddresscity.Text & ",Address_province=" & txtaddressprovince.Text _
& ",Address_postalcode=" & txtaddresspostalcode.Text & ",Address_country=" & txtaddresscountry.Text _
& ",Telephone_number=" & txttelephonenumber.Text & ",Fax_number=" & txtfacnumber.Text _
& "WHERE Customer_ID=" & txtcustomerid.Text
dbs.Execute sql, dbFailOnError
rCount = dbs.RecordsAffected
If rCount > 0 Then
MsgBox "Record Updated"
Updatecustomerbillto.Requery
End If
End Sub
Can anyone help me out, where I am making mistake in syntax
Have a good one
I am totally beginner in Access, just trying to learn myself during my free time
I am using unbound form, to update the record, but I am unable to update the record, as when i try to run the codes, Access giving me following error
The form, first pull the customer details from list box and based on clicking the record, filled the empty fields on the form (which works perfectly), but when i change the details, I am getting following error
Need help from Gurus of Access
Run-time error '2185':
You can't reference a property or method for a control unless the control has the focus
List box code (which work perfectly)
Private Sub Updatecustomerbillto_AfterUpdate()
txtcustomerid = Updatecustomerbillto.Column(0)
txtcustomername = Updatecustomerbillto.Column(1)
txtcontactperson = Updatecustomerbillto.Column(2)
txtaddressline1 = Updatecustomerbillto.Column(3)
txtaddressline2 = Updatecustomerbillto.Column(4)
txtaddressline3 = Updatecustomerbillto.Column(5)
txtaddresscity = Updatecustomerbillto.Column(6)
txtaddressprovince = Updatecustomerbillto.Column(7)
txtaddresspostalcode = Updatecustomerbillto.Column(8)
txtaddresscountry = Updatecustomerbillto.Column(9)
txttelephonenumber = Updatecustomerbillto.Column(10)
txtfaxnumber = Updatecustomerbillto.Column(11)
End Sub
Following are the code when i press the update button (to update the information in the table "Custbillingdetail" - when i click the debug button, following red area is highlighted with Yellow and last line marked as error
Private Sub Cmdupdatecustomerbillto_Click()
Dim dbs As DAO.Database, sql As String, rCount As Integer
txtcustomerid.SetFocus
If txtcustomerid = "" Then
MsgBox "Please select a record to update"
End If
Set dbs = CurrentDb
sql = "UPDATE Custbillingdetail Set Customer_Name=" & txtcustomername.Text _
& ",Contact_Person=" & txtcontactperson.Text & ",Address_line1=" & txtaddressline1.Text _
& ",Address_line2=" & txtaddressline2.Text & ",Address_line2=" & txtaddressline3.Text _
& ",Address_city=" & txtaddresscity.Text & ",Address_province=" & txtaddressprovince.Text _
& ",Address_postalcode=" & txtaddresspostalcode.Text & ",Address_country=" & txtaddresscountry.Text _
& ",Telephone_number=" & txttelephonenumber.Text & ",Fax_number=" & txtfacnumber.Text _
& "WHERE Customer_ID=" & txtcustomerid.Text
dbs.Execute sql, dbFailOnError
rCount = dbs.RecordsAffected
If rCount > 0 Then
MsgBox "Record Updated"
Updatecustomerbillto.Requery
End If
End Sub
Can anyone help me out, where I am making mistake in syntax
Have a good one