Villarreal68
Registered User.
- Local time
- Today, 02:48
- Joined
- Feb 15, 2007
- Messages
- 133
Hello Everyone,
I'm having an issue with this code:
I'm not an expert with VB, but I'm trying.
All I want to do is to select the value on Column(0) of my varItem on the Listbox to find the exisitng record and do an update to a date field.
I been looking at this code for about 3 days now and I can't figure out what's missing or wrong. I've read lots of posts similar to my code and it just looks fine to me. But the ugly meesage:
"91 - Oblect variable or With block variable not set" keeps on popping up.
Any help would be greatly appreciated.
I'm having an issue with this code:
Code:
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim ctl As Control
Dim varItem As Variant
On Error GoTo Err_btnAceptar
Set db = CurrentDb()
Set rst = CurrentDb.OpenRecordset("CheckOut")
'Make sure an item has been selected.
If ctl.ItemsSelected.count = 0 Then
MsgBox "Primero Selecciona un Territorio Para Aceptar."
Exit Sub
End If
Set ctl = Me.lstAfuera
For Each varItem In ctl.ItemsSelected
rst!Position = ctl.Column(0, varItem)
rst.Edit
rst!CheckInDate = Me.txtDate2
rst.Update
DoCmd.GoToRecord , , acGoTo, txtTerrIn
Me.TerrOut = False
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Aceptado"
Next varItem
Exit_btnAceptar:
rst.Close
Set rst = Nothing
Set ctl = Nothing
Me.lstAfuera.Requery
Me.lstDisponibles.Requery
Exit Sub
Err_btnAceptar:
If Err.Number = 3314 Then
MsgBox "Primero Asigna a un publicador."
Exit Sub
End If
If Err.Number = 3421 Then
MsgBox "Primero Asigna a un publicador."
Exit Sub
End If
MsgBox Err.Number & Err.Description
Resume Exit_btnAceptar
I'm not an expert with VB, but I'm trying.
All I want to do is to select the value on Column(0) of my varItem on the Listbox to find the exisitng record and do an update to a date field.
I been looking at this code for about 3 days now and I can't figure out what's missing or wrong. I've read lots of posts similar to my code and it just looks fine to me. But the ugly meesage:
"91 - Oblect variable or With block variable not set" keeps on popping up.
Any help would be greatly appreciated.