Could someone please tell me what is wrong with this module code?
I have a subform with 9 staff name fields that I want to call this sub procedure for each using OnNotInList instead of typing the code in for each field.
I also want to use it in the same way for a staff name field in my main form.
My public module name is "StaffAdd"
I have tried:
1) Private Sub fieldname_NotInList(NewData As String, Response As Integer)
Call addnew(Me) (tried with and w/out "Me")
End Sub
2)Private Sub fieldname_NotInList(NewData As String, Response As Integer)
Call StaffAdd.addnew
End Sub
3)Private fieldname_NotInList(NewData As String, Response As Integer)
Call addnew(strfirst, strLast)
End Sub
Public Sub AddName()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strfirst As String
Dim strLast As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Staff")
strfirst = Right(NewData, Len(NewData) - InStr(1, NewData, ",") - 1)
strLast = Left(NewData, InStr(1, NewData, ",") - 1)
With rs
.addnew
.Fields("last") = strLast
.Fields("first") = strfirst
.Update
End With
Response = acDataErrAdded
End Sub
I am not getting an error message and the new name I typed is in my project details table as it should be, it just isn't creating a new record in my Staff table. ??????
Thanks!
I have a subform with 9 staff name fields that I want to call this sub procedure for each using OnNotInList instead of typing the code in for each field.
I also want to use it in the same way for a staff name field in my main form.
My public module name is "StaffAdd"
I have tried:
1) Private Sub fieldname_NotInList(NewData As String, Response As Integer)
Call addnew(Me) (tried with and w/out "Me")
End Sub
2)Private Sub fieldname_NotInList(NewData As String, Response As Integer)
Call StaffAdd.addnew
End Sub
3)Private fieldname_NotInList(NewData As String, Response As Integer)
Call addnew(strfirst, strLast)
End Sub
Public Sub AddName()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strfirst As String
Dim strLast As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Staff")
strfirst = Right(NewData, Len(NewData) - InStr(1, NewData, ",") - 1)
strLast = Left(NewData, InStr(1, NewData, ",") - 1)
With rs
.addnew
.Fields("last") = strLast
.Fields("first") = strfirst
.Update
End With
Response = acDataErrAdded
End Sub
I am not getting an error message and the new name I typed is in my project details table as it should be, it just isn't creating a new record in my Staff table. ??????
Thanks!