I have a form to edit employee data that is a copy of the add employee form ( Which works great) with a list box at the top to select the employee to edit that is susposed to navigate to the correct record.
I am using the list box wizard to create the listbox and select the record. The problem is that it only works if i set the form to snapshot so I then can not edit the data.
It will navigate correctly and display the correct data if I have Snapshot sleected at the Record set type. If I have use "Dyanset" it displays the listbox. but nothing else on my form.
What am I doing wrong?
here is the code for the form if it helps.
I am using the list box wizard to create the listbox and select the record. The problem is that it only works if i set the form to snapshot so I then can not edit the data.
It will navigate correctly and display the correct data if I have Snapshot sleected at the Record set type. If I have use "Dyanset" it displays the listbox. but nothing else on my form.
What am I doing wrong?
here is the code for the form if it helps.
Code:
Option Compare Database
Private Sub First_name_Exit(Cancel As Integer)
popfullname
End Sub
Private Sub popfullname()
'Me.[Full name].value = Me.Last_Name.value & ", " & Me.First_name.value
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
TrackChanges Me
End Sub
Private Sub Last_Name_Change()
Debug.Print "Working"
Dim emp As String
Dim intIndex As Integer
Dim strSQL As String
Dim DB As Database
Dim rs As Recordset
Set DB = CurrentDb
emp = Chr(34) & "employee = " & Forms!Staffadd.employeeid.value & Chr(34)
Debug.Print emp
Debug.Print Forms![Staffadd]!employeeid
Debug.Print "dlookup is resolving to: "; DLookup("[containernumber]", "Access", "employee = " & Forms![Staffadd]!employeeid)
Debug.Print "Numnber of active containers at this time is: "; Me.containerlist.ListCount
If DLookup("[containernumber]", "Access", "employee = " & Forms![Staffadd]!employeeid) Then ' if Null then this employee has not been added to the containers access
Else
Debug.Print "Processing continer number: ";
For intIndex = 0 To Me.containerlist.ListCount - 1
Debug.Print Me.containerlist.ItemData(intIndex);
'Open the Contact table
Set rs = DB.OpenRecordset("SELECT * FROM Access", dbOpenDynaset)
With rs
'Set it to Add mode
.AddNew
'Enter the field values
.Fields("employee").value = Forms![Staffadd]!employeeid
.Fields("containernumber").value = Me.containerlist.ItemData(intIndex)
.Fields("Access").value = False
'Update it
.Update
'Close it
.Close
End With
Next intIndex
End If
Debug.Print " "
End Sub
Private Sub Last_Name_Exit(Cancel As Integer)
[Container access employee add subform].Requery
End Sub
Private Sub selID_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![selID], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Comment