My Assistant
![]() ![]() |
|
|
Apr 16 2009, 03:45 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 261 |
Here is a simple problem for someone programming in VBA, which is not my strength. I Have a form ASSET which has a combobox that selects the record to view, what i want to do is when I type in a barcode that is not already in the table I want it to automatically take me to add a new record. I am sure this is as simple as just modifiying the code in the IF then statement, however I do not have enough experiance to get the verbage correct.
CODE Private Sub Combo38_AfterUpdate() ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[Asset_Identification] = " & Str(Nz(Me![Combo38], 0)) If Not rs.EOF Then Me.Bookmark = rs.Bookmark End Sub Any one |
|
|
|
Apr 16 2009, 03:55 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 2,121 From: Lansing, MI USA |
How about?
CODE Private Sub Combo38_AfterUpdate() ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[Asset_Identification] = '" & Str(Nz(Me![Combo38], 0)) & "'" If rs.EOF Then DoCmd.GoToRecord , , acNewRec Else Me.Bookmark = rs.Bookmark End If End Sub Untested! |
|
|
|
Apr 16 2009, 04:11 PM
Post
#3
|
|
|
UtterAccess Addict Posts: 261 |
Tried that, no dice... suggestions?
|
|
|
|
Apr 16 2009, 04:33 PM
Post
#4
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
|
|
|
|
Apr 16 2009, 04:37 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 7,647 From: South coast, England |
You could try this in the Combo box's not in list event:
CODE DoCmd.RunCommand acCmdUndo DoCmd.GoToRecord , , acNewRec Response = acDataErrContinue or use this Not In List code in the code archives HTH |
|
|
|
Apr 16 2009, 05:27 PM
Post
#6
|
|
|
UtterAccess Addict Posts: 261 |
That worked!! Thank you, I was on the right path, but not being proficient with code yet it might have taken me 3 or 4 days...lol,, but I am learning.
Nice to know I have this great big resource, someday I will be on the other end of the question.. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th June 2013 - 04:53 AM |