M
Merwin12
Hi all:
I have this code for a combo box when a new entry in noton
a list:
Dim DB As Database
Dim rs As Recordset
Dim msg As String
Dim CR As String
CR = Chr(13)
'Exit if cboWTClocation is cleared
If NewData = "" Then Exit Sub
'Confirm
msg = " ' " & NewData & "' is not on the Training
Location list." & CR
msg = msg & "@ Do you want to add it?@"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again......", vbInformation, "IPMS -
WTC Survey"
Else
'user wants to add a new record
Set DB = DAO.DBEngine.Workspaces(0).Databases(0)
Set rs = DB.OpenRecordset("TlkpWTCTrainLocation",
dbOpenDynaset, dbSeeChanges)
On Error Resume Next
'Add a new record
rs.AddNew
rs![Train_loc_desc] = NewData
rs.Update
If Err Then
Response = acDataErrContinue
MsgBox Error$ & CR & CR & "Please try again.",
vbExclamation, "IPMS - WTC Survey"
Else
Response = acDataErrAdded
End If
End If
End Sub
on the after update event:
Me.Refresh
Me.requery
Problem:
After the update for the combo box, it goes from the
current record to the very first record if a user is
either adding to the list on the combo box or just editing
a record.
Please advise on how I can resolve this problem.
I have this code for a combo box when a new entry in noton
a list:
Dim DB As Database
Dim rs As Recordset
Dim msg As String
Dim CR As String
CR = Chr(13)
'Exit if cboWTClocation is cleared
If NewData = "" Then Exit Sub
'Confirm
msg = " ' " & NewData & "' is not on the Training
Location list." & CR
msg = msg & "@ Do you want to add it?@"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again......", vbInformation, "IPMS -
WTC Survey"
Else
'user wants to add a new record
Set DB = DAO.DBEngine.Workspaces(0).Databases(0)
Set rs = DB.OpenRecordset("TlkpWTCTrainLocation",
dbOpenDynaset, dbSeeChanges)
On Error Resume Next
'Add a new record
rs.AddNew
rs![Train_loc_desc] = NewData
rs.Update
If Err Then
Response = acDataErrContinue
MsgBox Error$ & CR & CR & "Please try again.",
vbExclamation, "IPMS - WTC Survey"
Else
Response = acDataErrAdded
End If
End If
End Sub
on the after update event:
Me.Refresh
Me.requery
Problem:
After the update for the combo box, it goes from the
current record to the very first record if a user is
either adding to the list on the combo box or just editing
a record.
Please advise on how I can resolve this problem.