Hello Everyone,
I am getting the runtime error when performing this.
1. I have a continuous form.
Scenario 1:
When a user selects an item (Say Item1) from the combo box1, several other Combo box/Text box value gets requery. (This is working well)
Scenario 2:
The user performs above action, then he goes to the second record set, tries to select (Item 5) from the combo box1, Now result should be all the record set's combo box1 should change to Item5, All the other combobox value gets locked. (This is working well too) Except I am getting an error message (3251).
Scenario 3:
The user Performs the first action as selecting Item 5, Now I am getting Runtime Error 3021.
I understand there is no current record. How to solve this.
Code for the after update event of the combo box:
Code:
Private Sub CmboElement_AfterUpdate()
If CmboElement.Value = 5 Then '5 = Non Billable Element
LResponse = MsgBox("Do you want to Proceed?", vbYesNo, "Note")
If LResponse = vbYes Then
PrintBttn.SetFocus
With Me.RecordsetClone
.MoveFirst
Do While .EOF = False
.Edit
.Fields("Saturday").Value = "0"
.Fields("Sunday").Value = "0"
.Fields("Monday").Value = "0"
.Fields("Tuesday").Value = "0"
.Fields("Wednesday").Value = "0"
.Fields("Thursday").Value = "0"
.Fields("Friday").Value = "0"
.Fields("ElementID").Value = 5
.Fields("ProjectID").Value = 268 '268 = Non Billable Project ID
Me.ProjectID = 268
Me.CmboProject.Locked = True
Me.CmboElement.Locked = True
Me.Monday.Locked = True
Me.Tuesday.Locked = True
Me.Wednesday.Locked = True
Me.Thursday.Locked = True
Me.Friday.Locked = True
Me.Saturday.Locked = True
Me.Sunday.Locked = True
.Update
.MoveNext
Loop
End With
RecordsetClone.Close
Set RecordsetClone = Nothing
Else
Me.CmboElement.SetFocus
Me.CmboProject.Locked = False
Me.Monday.Locked = False
Me.Tuesday.Locked = False
Me.Wednesday.Locked = False
Me.Thursday.Locked = False
Me.Friday.Locked = False
Me.Saturday.Locked = False
Me.Sunday.Locked = False
End If
Else
Me.CmboElement.SetFocus
Me.CmboProject.Locked = False
Me.Monday.Locked = False
Me.Tuesday.Locked = False
Me.Wednesday.Locked = False
Me.Thursday.Locked = False
Me.Friday.Locked = False
Me.Saturday.Locked = False
Me.Sunday.Locked = False
End If
End Sub