473,473 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Form Load using SQL HELP PLEASE

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
5 1815
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
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
4
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. ...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: nadeem_far | last post by:
Hello All, I am working on a .Net desktop application and I am having problem displaying a form. I am using C# and version 1.1 of the framework. here is how the code looks likes and I will...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
3
by: BakelNB | last post by:
I am new to the .Net environment, so please bear with me. I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.