PDA

View Full Version : Project VBA diplay Error94



elsg
02-16-2015, 02:17 PM
I try understand why my project display error94...

Runtime errror '94'Invaliduse of Null


lookup my file
https://www.sendspace.com/file/pk2gc1

Thank you!!!

p45cal
02-17-2015, 02:36 AM
With some 1400 lines of code in your file in 4 code-modules, at least give us a clue as to where this error occurs.
A bonus would be to tell us what the user is doing when the error occurs.

elsg
02-20-2015, 04:27 PM
Sorry, for the incomplete explanation, in UserForm "frmRegistoCrimes" a control, combobox, called cbx_Grupo.

try initialization this Userform.

p45cal
02-20-2015, 05:50 PM
There is reference in the code to a sheet called "Freguesias" where cbx_Grupo gets its values from. This sheet doesn't exist in the file you link to. Have you deleted it, or perhaps changed its name to Lista_Freguesias? If so change it back or alter the code with a search and replace.
This won't solve the problem though. It falls over because the combobox has no items in it when the AfterUpdate handler is called when you .cbx_Grupo.Enabled = False in the lsDesabilitar macro.
Without looking too deeply I made an adjustment to the following which you can try:
Private Sub cbx_Grupo_AfterUpdate()
If Not IsNull(Me.cbx_Grupo.List(Me.cbx_Grupo.ListIndex)) Then
Call CarregaMunicipio(Me.cbx_Grupo.List(Me.cbx_Grupo.ListIndex))
End If
End Sub