Welcome to SPN

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

Sign Up Now!

Verify info

Discussion in 'Information Technology' started by Tom, Jul 28, 2006.

Tags:
  1. Tom

    Tom
    Expand Collapse
    Guest

    Hi all,

    the user supposed to type in company name through a form into a table. when
    he exits or still working on the form I would like the DB to check if that
    company name is already in the list and if thats the case, give him a
    massage that that company name is already in the system


    Thanks,

    Tom
     
  2. Loading...

    Similar Threads Forum Date
    India India to verify reports of Chinese presence in PoK, says govt Breaking News Aug 31, 2010
    Need some info regarding bibek wrt eating Sikh Rehat Maryada Jan 14, 2016
    Events Nankana Sahib Saka (massacre) - Infographic History of Sikhism Feb 26, 2015
    India Indian ‘Journalist’ Slams Gurbaksh Singh Than Admits to Receiving Information from ‘Agencies’ Breaking News Dec 27, 2013
    Opinion West Punjab : Information Pool and Pictures Punjab, Punjabi, Punjabiyat Nov 18, 2013

  3. Arvin Meyer [MVP]

    Arvin Meyer [MVP]
    Expand Collapse
    Guest

    Something like this ought to work in the control's BeforeUpdate event:

    Private Sub txtCompanyName_BeforeUpdate(Cancel As Integer)
    On Error GoTo Err_Handler

    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String

    Set db = CurrentDb

    strSQL = "SELECT [CompanyName] FROM tblCompany WHERE [CompanyName] = """ &
    Me![txtCompanyName] & """"
    Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)

    If rst.RecordCount > 0 Then ' duplicate entry
    Cancel = True
    MsgBox "This Company is already in the database.", vbOKOnly, "Duplicate"
    End If

    Exit_Here:
    rst.Close
    Set rst = Nothing
    Set db = Nothing
    Exit Sub

    Err_Handler:
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Here

    End Sub
    --
    Arvin Meyer, MCP, MVP
    Microsoft Access
    Free Access downloads
    http://www.datastrat.com
    http://www.mvps.org/access

    "Tom" <partner1973@yahoo.com> wrote in message
    news:#IOIvv7dGHA.4932@TK2MSFTNGP03.phx.gbl...
    > Hi all,
    >
    > the user supposed to type in company name through a form into a table.

    when
    > he exits or still working on the form I would like the DB to check if

    that
    > company name is already in the list and if thats the case, give him a
    > massage that that company name is already in the system
    >
    >
    > Thanks,
    >
    > Tom
    >
    >
     
  4. Tom

    Tom
    Expand Collapse
    Guest

    Thanks Arvin, it`s working great.
    What do I need to add in order to clear the text box.
    I tried:

    Me.company=Null

    That doesnt work.

    Thanks for the help,
    Tom

    "Arvin Meyer [MVP]" <a@m.com> wrote in message
    news:%23Qoqe27dGHA.1856@TK2MSFTNGP03.phx.gbl...
    > Something like this ought to work in the control's BeforeUpdate event:
    >
    > Private Sub txtCompanyName_BeforeUpdate(Cancel As Integer)
    > On Error GoTo Err_Handler
    >
    > Dim db As DAO.Database
    > Dim rst As DAO.Recordset
    > Dim strSQL As String
    >
    > Set db = CurrentDb
    >
    > strSQL = "SELECT [CompanyName] FROM tblCompany WHERE [CompanyName] = """ &
    > Me![txtCompanyName] & """"
    > Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)
    >
    > If rst.RecordCount > 0 Then ' duplicate entry
    > Cancel = True
    > MsgBox "This Company is already in the database.", vbOKOnly,
    > "Duplicate"
    > End If
    >
    > Exit_Here:
    > rst.Close
    > Set rst = Nothing
    > Set db = Nothing
    > Exit Sub
    >
    > Err_Handler:
    > MsgBox Err.Number & ": " & Err.Description
    > Resume Exit_Here
    >
    > End Sub
    > --
    > Arvin Meyer, MCP, MVP
    > Microsoft Access
    > Free Access downloads
    > http://www.datastrat.com
    > http://www.mvps.org/access
    >
    > "Tom" <partner1973@yahoo.com> wrote in message
    > news:#IOIvv7dGHA.4932@TK2MSFTNGP03.phx.gbl...
    >> Hi all,
    >>
    >> the user supposed to type in company name through a form into a table.

    > when
    >> he exits or still working on the form I would like the DB to check if

    > that
    >> company name is already in the list and if thats the case, give him a
    >> massage that that company name is already in the system
    >>
    >>
    >> Thanks,
    >>
    >> Tom
    >>
    >>

    >
    >
     
  5. Arvin Meyer [MVP]

    Arvin Meyer [MVP]
    Expand Collapse
    Guest

    Since you should still me in txtCompanyName, I'd simply use a

    Me.txtCompanyName.Undo

    right after the Cancel statement.
    --
    Arvin Meyer, MCP, MVP
    Microsoft Access
    Free Access downloads
    http://www.datastrat.com
    http://www.mvps.org/access

    "Tom" <partner1973@yahoo.com> wrote in message
    news:OmJV4p8dGHA.1856@TK2MSFTNGP03.phx.gbl...
    > Thanks Arvin, it`s working great.
    > What do I need to add in order to clear the text box.
    > I tried:
    >
    > Me.company=Null
    >
    > That doesnt work.
    >
    > Thanks for the help,
    > Tom
    >
    > "Arvin Meyer [MVP]" <a@m.com> wrote in message
    > news:%23Qoqe27dGHA.1856@TK2MSFTNGP03.phx.gbl...
    > > Something like this ought to work in the control's BeforeUpdate event:
    > >
    > > Private Sub txtCompanyName_BeforeUpdate(Cancel As Integer)
    > > On Error GoTo Err_Handler
    > >
    > > Dim db As DAO.Database
    > > Dim rst As DAO.Recordset
    > > Dim strSQL As String
    > >
    > > Set db = CurrentDb
    > >
    > > strSQL = "SELECT [CompanyName] FROM tblCompany WHERE [CompanyName] = """

    &
    > > Me![txtCompanyName] & """"
    > > Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)
    > >
    > > If rst.RecordCount > 0 Then ' duplicate entry
    > > Cancel = True
    > > MsgBox "This Company is already in the database.", vbOKOnly,
    > > "Duplicate"
    > > End If
    > >
    > > Exit_Here:
    > > rst.Close
    > > Set rst = Nothing
    > > Set db = Nothing
    > > Exit Sub
    > >
    > > Err_Handler:
    > > MsgBox Err.Number & ": " & Err.Description
    > > Resume Exit_Here
    > >
    > > End Sub
    > > --
    > > Arvin Meyer, MCP, MVP
    > > Microsoft Access
    > > Free Access downloads
    > > http://www.datastrat.com
    > > http://www.mvps.org/access
    > >
    > > "Tom" <partner1973@yahoo.com> wrote in message
    > > news:#IOIvv7dGHA.4932@TK2MSFTNGP03.phx.gbl...
    > >> Hi all,
    > >>
    > >> the user supposed to type in company name through a form into a table.

    > > when
    > >> he exits or still working on the form I would like the DB to check if

    > > that
    > >> company name is already in the list and if thats the case, give him a
    > >> massage that that company name is already in the system
    > >>
    > >>
    > >> Thanks,
    > >>
    > >> Tom
    > >>
    > >>

    > >
    > >

    >
    >
     

Share This Page