UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Record not in combobox, add new record    
 
   
dmiles
post 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
Go to the top of the page
 
+
SerranoG
post 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!
Go to the top of the page
 
+
dmiles
post Apr 16 2009, 04:11 PM
Post #3

UtterAccess Addict
Posts: 261



Tried that, no dice... suggestions?
Go to the top of the page
 
+
Jack Cowley
post Apr 16 2009, 04:33 PM
Post #4

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



Use the Combos Not In List event... This article shows you two methods...

hth,
Jack
Go to the top of the page
 
+
pere_de_chipstic...
post 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
Go to the top of the page
 
+
dmiles
post 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 the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 04:53 AM