By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

Form Load using SQL HELP PLEASE

P: n/a
I have an acceed db where I am passing UID (User ID) from one form to
another. I need that to do a SQL statement to select records that are
assigned to the UID. Here is my code and it works sometimes but not
all the time. For instance when I log in as user 1 and it works but
then I changed to user 2 and the first time I go in it does not work
but the second time it works. It would appear that the sql statement
is not running everytime. Can anybody help PLEASE!!!!

My Code

Dim UID As String

UID = GetTagFromArg(Me.OpenArgs, "value")

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As String
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("que_Sales_rep")
db.QueryDefs.Refresh
strCriteria = "'" & UID & "'"

strSQL = "select * from [SAL_Sales Tracking Data] where [SAL_Sales
Tracking Data].[Assigned To] =(" & strCriteria & "); "
qdf.SQL = strSQL
Set db = Nothing
Set qdf = Nothing

May 23 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
What you're doing is unsafe if there can ever be more than one user in the
same MDB at the same time.

If the form you're using is a bound form, which I assume it must be in order
for the query to supply the data for it, then you might consider opening the
second form like this:

dim strWhere as string

strWhere = "[SAL_Sales Tracking Data].[Assigned To] = '" & me.txtUID & "'"

docmd.OpenForm "mydataform", acNormal, ,strWhere

In this code, me.txtUID refers to the control that contains the UID value
you want to use for filtering. It must already exist on the form you're
using to open the second form, so just change the name to whatever control
you already have.

If you use this technique, you can scrap all the code you posted, because it
would be unnecessary.

HTH
May 23 '06 #2

P: n/a
Thanks for the help but when I switch from user to user only the first
user is working. What could I be doing wrong.

May 23 '06 #3

P: n/a
"wmdamonj" <jd*****@wm.com> wrote in
news:11*********************@j73g2000cwa.googlegro ups.com:
Thanks for the help but when I switch from user to user only
the first user is working. What could I be doing wrong.

Do the other users have the necessary permissions to modify the
query? the form?

--
Bob Quintal

PA is y I've altered my email address.
May 23 '06 #4

P: n/a
I have a drop down box with the user names and I am going from one user
to another user. So the only person on the system right now is me.

May 24 '06 #5

P: n/a
I have a drop down box with the user names and I am going from one user
to another user. So the only person on the system right now is me.

May 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.