Link to home
Start Free TrialLog in
Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

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?
Avatar of MINDSUPERB
MINDSUPERB
Flag of Kuwait image

You might try the After Update Event of the combo box.

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
ASKER CERTIFIED SOLUTION
Avatar of HKFuey
HKFuey
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HKFuey

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?
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?
Avatar of HKFuey

ASKER

Thanks for the help!