RE: Help With "NotInList"
- From: Jeff C <JeffC@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 10 Aug 2006 08:43:02 -0700
Klatuu:
Thanks for your help, I can't get the thing to workyet.
I tried your code also and get the same thing happening. I enter the new
account number, it lets me add it but the rest of the fields fill on the form
with data from a different record. When I check the table the new record has
indeed been added and the other fields are blank.
My original code was:
NOTINLIST Event
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Patients", dbOpenDynaset)
rs.AddNew
[rs]![MR#] = NewData
rs.Update
Response = acDataErrAdded
Set rs = Nothing
Set db = Nothing
And I also have this:
AfterUpdate Event
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PTID] = " & Str(Nz(Me![Combo65], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
This is a bugger for me.
--
Jeff C
Live Well .. Be Happy In All You Do
"Klatuu" wrote:
We would have to see the code in your Not In List event to know what the.
error might be.
Here is an example of one that works. Once you have said you want to add
the record, it make the new record the current record:
Private Sub cboActivity_NotInList(NewData As String, Response As Integer)
Dim rst As Recordset
If MsgBox(NewData & " Is Not In The Attribute Table " & vbNewLine _
& "Do you want to add it", _
vbInformation + vbYesNo, "Not Found") = vbYes Then
CurrentDb.Execute ("INSERT INTO CISAttributeTable (ACTIVITY) " _
& "VALUES ('" & NewData & "');"), dbFailOnError
Me.Requery
Set rst = Me.RecordsetClone
rst.FindFirst "[Activity] = '" & NewData & "'"
Me.Bookmark = rst.Bookmark
Set rst = Nothing
Me.txtDescription.SetFocus
Response = acDataErrAdded
Else
Me.cboActivity.Undo
Response = acDataErrContinue
End If
End Sub
"Jeff C" wrote:
I have a one to many set up with corresponding form and subform. Focus
begins on a combo box where account number is entered to either add a new
record and corresponding audits or pull up existing record to add another
audit. The account number field in the table is set to indexed no duplicates.
The afterupdate event of the combobox is set to open the corresponding
record of the account number entered.
The "NotInList" fires and accepts the new entry when prompted however
corresponding data from a different record fills in the textboxes rather than
being blank to accept new data.
Where am I going wrong? Thanks.
--
Jeff C
Live Well .. Be Happy In All You Do
- Follow-Ups:
- RE: Help With "NotInList"
- From: Klatuu
- RE: Help With "NotInList"
- Prev by Date: Re: copy data between forms automatically
- Next by Date: Re: Access files being opened on multiple computers
- Previous by thread: Make MDE File not selectable
- Next by thread: RE: Help With "NotInList"
- Index(es):
Relevant Pages
|