HKFuey
asked on
Access form error
Hi,
I have a form that uses a query on a single table as a record source, I want to change one record on click of a combo so I added this to the click event: -
sql = "SELECT tbl_Complaints.IdNumber, tbl_Complaints.TxtCategory "
sql = sql & "From tbl_Complaints "
sql = sql & "WHERE tbl_Complaints.IdNumber=" & Me!IdNumber
Set Rst = Dbs.OpenRecordset(sql, dbOpenDynaset, dbSeeChanges)
If Rst.RecordCount > 0 Then
Rst.Edit
If Me!CboCompCat = "None" Then
Rst!TxtCategory = ""
Else
Rst!TxtCategory = Me!CboCompCat
End If
Rst.Update
End If
If the user changes a record on the form and then clicks the combo they get an error. I can't seem to replicate this and they are using Access runtime so I can't identify the error.
Can anyone help?
I have a form that uses a query on a single table as a record source, I want to change one record on click of a combo so I added this to the click event: -
sql = "SELECT tbl_Complaints.IdNumber, tbl_Complaints.TxtCategory
sql = sql & "From tbl_Complaints "
sql = sql & "WHERE tbl_Complaints.IdNumber=" & Me!IdNumber
Set Rst = Dbs.OpenRecordset(sql, dbOpenDynaset, dbSeeChanges)
If Rst.RecordCount > 0 Then
Rst.Edit
If Me!CboCompCat = "None" Then
Rst!TxtCategory = ""
Else
Rst!TxtCategory = Me!CboCompCat
End If
Rst.Update
End If
If the user changes a record on the form and then clicks the combo they get an error. I can't seem to replicate this and they are using Access runtime so I can't identify the error.
Can anyone help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The form is bound to the table, yes.
The error they got was "Runtime Error", not very helpful. They have been working on it since I did the changes without problem, so I'll just have to wait...
Re: "If so, then why don't you just make the [TxtCategory] a bound control on the form. Then you don't need this additional code."
I'm using a combo box to assign category then refresh the form behind, will this method work?
The error they got was "Runtime Error", not very helpful. They have been working on it since I did the changes without problem, so I'll just have to wait...
Re: "If so, then why don't you just make the [TxtCategory] a bound control on the form. Then you don't need this additional code."
I'm using a combo box to assign category then refresh the form behind, will this method work?
How is the table bound to the form? Is the RecordSource of the form the table, or is it a query (this really doesn't matter as long as the query can be updated)?
Can you take a screen shot of your form and post it here?
Can you take a screen shot of your form and post it here?
ASKER
Thanks for the help!
If you can post a sample DB, with only the form and a table/s in question we can see clearly the issue.
Sincerely,
Ed