View Full Version : Refrencing table records


arage
01-02-2001, 11:25 AM
Refrencing table records
Hi,
The following code is my attempt at accessing a table called password & checking fields in it called region code & password against the text controls on my form. Its not working though. How can I match my unbound fields with a record in a table? I get errors that field tables (!) is not accessible by axs97 so there is a problem b/c that’s the table name not field name.
Thanks!

If Me!txtRegionCode = [tables]![passwords]!RegionCode Then

If Me!txtPassword = [tables]![passwords]!Password Then
stDocName = "Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

MsgBox "You have not been authorized to use this program.", vbExclamation, "RE-LOGIN"
Exit Sub
End If

Pat Hartman
01-02-2001, 02:48 PM
The following is a sample that runs a query to determine if someone is authorized for a particular function. In your case you would use UserId and Password as the parameters. Following the code snippet is the parameter query that it runs.


Dim WgtDB As Database
Dim strSQL As String
Dim QD1 As QueryDef
Dim TempSet1 As Recordset
Set WgtDB = CodeDb
Set QD1 = WgtDB.QueryDefs!QCheckAuthorization
QD1.Parameters![UserId] = Forms!frmLogOn!txtUSER_ID
QD1.Parameters![AuthType] = "AUTHORIZ"
Set TempSet1 = QD1.OpenRecordset
If TempSet1.EOF Then
MsgBox "You have not been authorized to use this program.", vbExclamation, "RE-LOGIN"

End If


The following is the QCheckAuthorization query:

PARAMETERS UserID Text, AuthType Text;
SELECT A.USER_ID, A.AUTH_TYP
FROM DBO_USER_AUTH AS A
WHERE ((([A].[USER_ID])=[UserID]) AND (([A].[AUTH_TYP])=[AuthType] Or ([A].[AUTH_TYP])="SUPPORT"));


[This message has been edited by Pat Hartman (edited 01-02-2001).]

TGHockett
01-02-2001, 07:37 PM
Pat H. or others ... any ideas how this same purpose can be accomplished via a macro?

TGH

arage
01-03-2001, 05:25 AM
Hi Pat,
i appreciate your help but i'm unaware how to implement the qchkqry you mention below. i'm only experienced at using a wizard to make the query as of now so for the moment i'm going to try to use vba with a dlookup. please look for my new posts re: this problem of mine below in the module/vba forum i think that's where these questions of mine shud go. thanks much tho.