Solution for ms access invalid IDA error 7879 - ms-access

I've made an Access database with a connection to a DWH table. A form with 3 drop-down boxes is made for the user to select the correct value. But the first time a drop-down value is selected the user receives an error (in Dutch). 'An invalid IDA has been passed to Microsoft Access error handling. Please report this error and the steps that caused it.'
After clicking 'Ok' the error doesn't show up when selecting a value form the second drop-down box (and the third) in the same form. Only when the user selects this form again the error pops up when selecting the first drop-down value.
The only VBA code linked to this form is:
Option Compare Database
Private Sub Form_Load()
Me.AantalVanCONTRACT_NUMBER.ColumnWidth = 1.556 * 1440
End Sub
The strange thing is that the form works fine because the selected value gets inputted in the DWH table, but getting this error every time is pretty annoying.

Related

How can I fix the Error handler for my Macro in MS Access

I have a form that has buttons that view a record based on where [ID]=[Contact Name].
However, when the rows are blank, and the button is clicked I receive the error
Syntax error(missing operater)in query expression [id]
I am currently using the on click macro which opens the form to the condition:
="[ID]=" & [Contact Name]
I have attempted the on error method, however it still shows the standard MS Access error warning (Syntax error(missing operater)in query expression [id]) before showing mine which is "no contact in field"enter image description here

MS Access form ID increment

I'm trying to set up a simple form in MS access to add a new record to a table full of contact information. Each time I add a new record using the form, I want an ID number field to increment by one against whatever the highest value in the ID field is. The code I have right now seems to be working:
Private Sub Contact_ID_Click()
Dim newContactID As Double
newContactID = DMax("[Contact_ID]", "Contacts") + 1
Contact_ID = newContactID
End Sub
The problem is that every time I start the database, open up the form in form view and click on the Contact_ID field to increment it, I get the following error message:
"The expression On Click you entered as the event property setting produced the following error: Object or class does not support the set of events."
I go to design view, open up the code, and then as soon as I switch back to Form view it's working again. I'd like it to work when the form is opened from scratch as others might be using this form and wouldn't know what to do. Any idea what's causing this?

How to check if an empty record is clicked in an Access subform?

I have a subform embedded in a main form. I have the following code for the onClick event of one field in my subform.
Private Sub my_field_Click()
If Not Me!my_field.Value Is Null Then
'my code here...
End If
End Sub
I want to update a text box with a click on the field, but I got an error when I click the field before the subform is not fully initiated (by setting the field's data source). So I wrote the above code to check if there is any value now in the field. However, I got the run-time error 424: Object required when running this code. Strangely, when I inspect the value of Me!my_field.Value in the debug window at run time, it does give NULL value.
Any idea what went wrong here? What else should I do to do this checking?
I am running this in Access 2000.
Use the IsNull() function in VBA code.
If Not IsNull(Me!my_field.Value) Then

Setting Combobox.Selected programmatically, but I cannot get a selection to appear

So in MS Access 2010 I have a main form for viewing client details, and tabbed subform navigation with subforms showing information in different tables for said client. On one page, i have a combobox to select a date for viewing a testing session related to the client. I am trying to get the first combobox value to be selected automatically when the user goes to this tab and/or cycles through other users while viewing this tab. My simple VB code is below:
Private Sub Form_Current()
Me.DateOfScreening.Requery
Me.DateOfScreening.Selected(2) = True
End Sub
The requery command is executing (paging through different clients will update the combobox values, and commenting that line out stops that behavior, so I know this code block is getting executed), but the Selected command appears to not select anything.
I hope I am just missing something obvious
For some reason, setting the selected row index for a combo box has not behaved well for me.
Could you just set the combobox value directly, as in
Me.DateOfScreening = "yourValue"
Also, when referencing the control, you can use either
me.dateofScreening.column(0) 'if 0 is your bound col index
or maybe
me.dateofScreening.itemdata(0)
Also, could you do a debug.print(me.dateofScreening.column(0)) or msgbox (me.dateofScreening.column(0)) and let me know if it says anything.

Form On Error handling

I am trying to improve my error handling code.
Using Access (2007) VBA:
When an error occurs in the forms On Error handler the variable DataErr gives me the error code but I have no access to the Err object.
Access to the Err object allows me to parse the error description and give a detailed custom message (eg error code 3314 exactly which field is causing the error) to the user
How can I have access to the Err object from the form's OnError handler? Not only the error code
Note:
I can access the Err object from code attached to the "save" and "delete" buttons on my form and give customised messages for duplicate keys, missing required fields, linked reecords that can not be deleted,etc.
This works fine if the user clicks these button. But if the user decides to select the next or previous row - which causes a save to occur - my code is not called and the user gets shown the standard MS Access error message
"if the user decides to select the next or previous row - which causes a save to occur - my code is not called and the user gets shown the standard MS Access error message"
Use the form's Before Update and Before Insert events to validate the current values. If any are unacceptable, you can assign True to the procedure's Cancel parameter, and notify the user about invalid values.