Results 1 to 2 of 2
  1. #1
    gracysaurus is offline Novice
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    2

    If Not Found, then New?

    relatively new to VBA, but have a working 'search' box for my form. Below is the code, and the row source is a query which takes all the names from the Table1.
    Form1 and Form2 display the names from Table1 in locked combo boxes (to prevent accidental editing) and the remainder of the forms can be filled in or edited.
    The problem is I need to add code such that when a name is pulled up from Table1 in Form2 where there is no record yet the form will create a new record with just the name filled in.


    I imagine it has something to do with an
    Code:
    If 'not found' Then oCmd.GoToRecord , , acNewRec
    But i don't know what goes in the If statement.
    Help!

    Code for search box:
    Code:
    Private Sub cboFind_AfterUpdate()
    Me.AllowEdits = True
    DoCmd.ShowAllRecords
        Me!Last_Name.SetFocus
        DoCmd.FindRecord Me!cboFind, acEntire, , acSearchAll, , acEntire, True
    
    End Sub

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    you would run a query to select the count of whatever you are looking for. your 'not found' would mean count = 0.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Specified SQL server not found
    By danparker in forum Access
    Replies: 3
    Last Post: 10-25-2011, 03:23 PM
  2. Query not found, but it is there
    By Gdm in forum Queries
    Replies: 5
    Last Post: 05-21-2010, 05:59 AM
  3. Query Not Found
    By brooke48 in forum Queries
    Replies: 23
    Last Post: 04-17-2010, 10:51 AM
  4. Item not found
    By thart21 in forum Programming
    Replies: 7
    Last Post: 04-14-2010, 10:41 AM
  5. Module not found
    By nooby in forum Modules
    Replies: 1
    Last Post: 12-02-2009, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums