SQL Insert issue? (1 Viewer)

calvinle

Registered User.
Local time
Yesterday, 23:41
Joined
Sep 26, 2014
Messages
332
Hi,

I usually work with DAO, but since I know SQL is faster, so I start using it. Why does this code works for me, but not to my colleague?

Code:
 CurrentDb.Execute "INSERT INTO tblConnect (user_id) VALUES ('" & NetworkUserName & "');", dbFailOnError

I try to collect all username that connect to my database, so "On Load" event of the form, it will add their username to the linked table.

Is anything wrong with the code?

Thank you.
 

Minty

AWF VIP
Local time
Today, 07:41
Joined
Jul 26, 2013
Messages
10,379
What error code is the failure generating? Can the other user write to that table.
 

Ranman256

Well-known member
Local time
Today, 02:41
Joined
Apr 9, 2015
Messages
4,337
What do you mean 'does not work'?
It throws an error?
It puts nothing in the table?
 

calvinle

Registered User.
Local time
Yesterday, 23:41
Joined
Sep 26, 2014
Messages
332
When I open it and I check in the tblConnect backend, it shows my network user. When someone else open it, it doesnt show their user network id.

There is no error appearing. It looks like it added, but nothing. So I did a test to msgbox to see their username On Open, the msgbox prompt their network user.

But it doesnt add to the table.
 

JHB

Have been here a while
Local time
Today, 08:41
Joined
Jun 17, 2012
Messages
7,732
Is user_id a number field type or a text field type, (then you're applying a text to it)?
VALUES ('" & NetworkUserName & "')
 

calvinle

Registered User.
Local time
Yesterday, 23:41
Joined
Sep 26, 2014
Messages
332
Oh aha, text. I think I got why its not working. The user does not have writing access to the backend where the tblConnect is stored. Thats why it cannot write to the table.
 

Users who are viewing this thread

Top Bottom