Re: Checking for value in a table



If I understand what you are trying to do, you want to check if the record
exist and if it doesn't add it to the table

Dim MyDB As DAO.DataBase, MyRec As Dao.RecordSet

Set MyDB=CurrentDB
Set MyRec = MyDB.OpenRecordSet("Select * From TableName Where
UsernameFieldName = '" Me.Username "'")
If MyRec.Eof Then
' Doesn't exist
MyRec.AddNew
MyRec!Username = Me.Username
MyRec.Update
Else
MsgBox "Username exist"
End If
===================================================
' I hope that will get you started, if the field you are looking for is
number type use that
Set MyRec = MyDB.OpenRecordSet("Select * From TableName Where
UsernameFieldName = " Me.Username)
==================================================
I assumed that you are looking for a field value in a form and this is why I
used Me.Username, if it is a different variable then use yours

--
Please respond to the group if your question been answered or not, so other
can refer to it.
Thank you and Good luck



"BobbyS" wrote:

> Thanks tina, but I guess I didn't explain well enough what I wanted to do.
>
> I have a table with three fields.
>
> I need to search the first field/column (Criteria) for a specific value, say
> the text value "Username" then return the the value in the second column
> (Setting) of that record an open recordset (rstNewUser). Thanks
>
>
> "tina" wrote:
>
> > suggest you try using a DLookup() function, rather than opening a recordset
> > based on a SQL statement. see Access Help for more information on the
> > function. and btw, if you really have a field in your table named "Value",
> > suggest you change it. Value is a property of controls in forms and reports,
> > and using it as the name of something you created (a field in a table) may
> > very likely cause problems.
> >
> > hth
> >
> >
> > "BobbyS" <BobbyS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:4DD68FEB-20B9-4FF4-97C2-48178A4043CC@xxxxxxxxxxxxxxxx
> > > How would I write an SQL statement that would find the value (from a
> > variable
> > > strCheck) in a table (tblNames) in field named [Value]? and if that exists
> > > then GoTo GetMeOut?
> > >
> > > Thank you.
> >
> >
> >
.



Relevant Pages

  • Re: max min question
    ... > say username is TOM ... SELECT max,min,sumFROM tablename ... to use a query to normalize this data. ... "qNormalizedData" using this sql (it's a union query): ...
    (microsoft.public.inetserver.asp.db)
  • Re: max min question
    ... Instead of one row for each username, there would be 6 for each, thus making ... > Your table design is not normalized, making this a much more difficult ... > SELECT max,min,sumFROM tablename ... > union all ...
    (microsoft.public.inetserver.asp.db)
  • Re: Replace Values instead by FORM
    ... MyDb.OpenRecordset("SELECT * FROM TableName WHERE PrimaryKeyField= ... Set MyRec = MyDB.OpenRecordset("Select * From TableName Order By ... MyRec!MyNum = OldValue ... It'd be appreciate if the "QUERY" can do instead of inputing values by ...
    (microsoft.public.access.queries)
  • WebServices Security...
    ... I've my .NET 2.0 C# WebApplication which exposes some WebMethod, ... tablename, username, password and I get a DataSet with some data (actually ... webmethod call can call it with the same password and username and retrieve ...
    (microsoft.public.dotnet.framework.webservices)
  • Is it possible to sql inject this code?
    ... ALTER PROCEDURE Sp_Login ... (@username as nvarchar(100),@password as nvarchar) ... Prev by Date: ...
    (microsoft.public.sqlserver.security)