Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

RE: Searching if Record is in Table

Discussion in 'Information Technology' started by ftrujill0, Nov 9, 2005.

  1. ftrujill0

    ftrujill0
    Expand Collapse
    Guest

    OFER - YOU ARE THE MAN!!!! THANK YOU! ;-)

    "Ofer" wrote:

    > Create a field in the form that is unbound, where you can type the number you
    > want to search for
    >
    > On the after upate event of the field run the code
    >
    > ' check if the record exist
    > If IsNull(DLookup("FieldName", "TableName", "FieldName='" &
    > Me.FieldnameInTheForm & "'")) Then
    > ' if the record doesn't exist we'll move to a new record, and add the
    > number to the real field that is bound to the table
    > DoCmd.GoToRecord , , acNewRec
    > Me.RealFieldName = Me.FieldName
    > Else
    > ' if the record exist we'll apply a filter and move to that record
    > Me.Filter = "FieldName = '" & Me.FieldName & "'"
    > Me.FilterOn = True
    > End If
    >
    > ============================================
    > ' In this code sample I assume that the field is text, if the field is a
    > number type, then use this
    >
    > ' check if the record exist
    > If IsNull(DLookup("FieldName", "TableName", "FieldName=" &
    > Me.FieldnameInTheForm)) Then
    > ' if the record doesn't exist we'll move to a new record, and add the
    > number to the real field that is bound to the table
    > DoCmd.GoToRecord , , acNewRec
    > Me.RealFieldName = Me.FieldName
    > Else
    > ' if the record exist we'll apply a filter and move to that record
    > Me.Filter = "FieldName = " & Me.FieldName
    > Me.FilterOn = True
    > End If
    > =======================================================
    > --
    > I hope that helped
    > Good luck
    >
    >
    > "ftrujill0" wrote:
    >
    > > Can someone help me put together the vba code that would search an access
    > > table for a record entered into a form field and if the record is not found
    > > enable the data entry fields to create the new record into the table.
    > >
    > > Example of problem.
    > > Is record 121212 in table X?
    > > If so, return record 121212 already exists in table X.
    > > If not, allow enable the data entry fields (name, address, etc...)
    > >
    > > THANKS IN ADVANCE.
    > >
    > >
    > >
     
  2. Loading...

    Similar Threads Forum Date
    World War 1 Sikh-Canadian Pioneers: Still Searching for Our Sikh War Heroes History of Sikhism Feb 20, 2011
    Sikh News US to begin searching Sikh turbans (Bangkok Post) Breaking News Sep 3, 2007
    Sikh News Sikh community condemns policy on searching turbans (Oakland Tribune) Breaking News Aug 29, 2007
    Searching for an answer Spiritual Articles Mar 22, 2006
    Soul-searching Doctors Find Life After Death Interfaith Dialogues Nov 15, 2004

  3. Ofer

    Ofer
    Expand Collapse
    Guest

    Your welcome

    --
    The next line is only relevant to Microsoft''s web-based interface users.
    If I answered your question, please mark it as an answer. It''s useful to
    know that my answer was helpful
    HTH, good luck


    "ftrujill0" wrote:

    > OFER - YOU ARE THE MAN!!!! THANK YOU! ;-)
    >
    > "Ofer" wrote:
    >
    > > Create a field in the form that is unbound, where you can type the number you
    > > want to search for
    > >
    > > On the after upate event of the field run the code
    > >
    > > ' check if the record exist
    > > If IsNull(DLookup("FieldName", "TableName", "FieldName='" &
    > > Me.FieldnameInTheForm & "'")) Then
    > > ' if the record doesn't exist we'll move to a new record, and add the
    > > number to the real field that is bound to the table
    > > DoCmd.GoToRecord , , acNewRec
    > > Me.RealFieldName = Me.FieldName
    > > Else
    > > ' if the record exist we'll apply a filter and move to that record
    > > Me.Filter = "FieldName = '" & Me.FieldName & "'"
    > > Me.FilterOn = True
    > > End If
    > >
    > > ============================================
    > > ' In this code sample I assume that the field is text, if the field is a
    > > number type, then use this
    > >
    > > ' check if the record exist
    > > If IsNull(DLookup("FieldName", "TableName", "FieldName=" &
    > > Me.FieldnameInTheForm)) Then
    > > ' if the record doesn't exist we'll move to a new record, and add the
    > > number to the real field that is bound to the table
    > > DoCmd.GoToRecord , , acNewRec
    > > Me.RealFieldName = Me.FieldName
    > > Else
    > > ' if the record exist we'll apply a filter and move to that record
    > > Me.Filter = "FieldName = " & Me.FieldName
    > > Me.FilterOn = True
    > > End If
    > > =======================================================
    > > --
    > > I hope that helped
    > > Good luck
    > >
    > >
    > > "ftrujill0" wrote:
    > >
    > > > Can someone help me put together the vba code that would search an access
    > > > table for a record entered into a form field and if the record is not found
    > > > enable the data entry fields to create the new record into the table.
    > > >
    > > > Example of problem.
    > > > Is record 121212 in table X?
    > > > If so, return record 121212 already exists in table X.
    > > > If not, allow enable the data entry fields (name, address, etc...)
    > > >
    > > > THANKS IN ADVANCE.
    > > >
    > > >
    > > >
     

Share This Page