By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

create new record and start editing

P: 2
hi,
i'm trying to do a simple thing i thought: a form with a pulldown menue looks up a record based on the menue enrty selected (findfirst). i want to use the "not in list" event to add a record. that works just fine. now after the new record is created how do i get the form to open this record so that i can populate the remaining fields? i have the record id but when i try to do a findfirst on that id access gets into an endless loop.

Thanks
Mar 9 '10 #1
Share this Question
Share on Google+
3 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Please show us the code you are using, then we can work of that.
Mar 9 '10 #2

P: 2
here is the code for the pulldown (wizzard generated)

Private Sub Combo14_AfterUpdate()
' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[REQUEST_ID] = " & Str(Nz(Me![Combo14], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Exit Sub


End Sub

This is the "not in list" event

Private Sub Combo14_NotInList(newdata As String, Response As Integer)
Dim no As Integer
Dim db As Database
Dim varbkmk As Variant

Set db = CurrentDb
Dim RS As Object
sqlstr = "SELECT RQ.[RQ number], rq.request_id FROM RQ" & ";"
Set RS = db.OpenRecordset(sqlstr)


RS.AddNew
RS.Fields("RQ number") = newdata
no = RS.Fields("request_id")
RS.Update
RS.Close
Response = acDataErrAdded

AND HERE I WOULD LIKE TO OPEN THE RECORD I JUST CREATED FOR EDITING

End Sub


cheers
Mar 19 '10 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Hi again.

Been on vacation, sorry for the late reply. Try adding this at the bottom:
Expand|Select|Wrap|Line Numbers
  1. Me.Requery
  2. Me.recordset.findfirst "request_id"
  3.  
I haven't tried using the approach you describe, so I am guessing what should be done, so if its not working, just return here, and we can try a bit more.

You should also remember to unassign your objects. Basicly if you are using a Set command, you should remember to unset it when you exit.
Expand|Select|Wrap|Line Numbers
  1. Set Rs=Nothing
  2. Set db=Nothing
  3.  
Apr 5 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.