Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 12th, 2007, 10:29 AM
Posts: n/a
Default Invalid Argument

Hi I have a table with users name who are permitted to se certain parts of a form. On the form I have a function that obtains the username and asigns it to a text box.

What I want to do is when the form opens is run a query that checks the table to see if the user is listed if he is then enable certain buttons on the form. If he is not there then disable the buttons.
The code I have attempted is as follows:

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strResult, strUser
Dim sSQL As String
Const cQUOTE = """"

txtUser = OSUserName

Set db = CurrentDb()
sSQL = "SELECT tblAdminUsers.Username FROM tblAdminUsers WHERE tblAdminUsers.Username=" & cQUOTE & Me![txtUser] & cQUOTE

Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)

strResult = rs

If Me.txtUser = strResult Then
    Me.cmdUsers.Visible = True
    Me.cmdUsers.Visible = False
End If

I have tried several variations on this without success, I keep getting the following error:

Runtime error 3001 Invalid argument

Any help would be gratefully received

Reply With Quote
  #2 (permalink)  
Old May 14th, 2007, 09:53 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

An easier way to do this is to get the user information at start up and post it to a form, and then hide the form (acHidden) when you open it. Put the user's access level in this form too. I use a Group like Administrator, User, etc.

Then on the on format event of the form's detail section, or on the on load event of the form, check the value in the text box on the hidden form, and set the buttons etc to visible based on the user.

Then no queries needed, which are problematic with data latency issues anyway.

Did that help any?

Reply With Quote
  #3 (permalink)  
Old May 14th, 2007, 10:11 AM
Posts: n/a

Thanks very much for your reply - sounds good to me - I will give it a try and let you know
Thanks again
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid argument supplied for foreach() codejockey Beginning PHP 4 September 24th, 2010 03:40 AM
Invalid postback or callback argument mallikalapati ASP.NET 2.0 Professional 4 February 20th, 2008 08:38 AM
Invalid postback or callback argument everest ASP.NET 2.0 Professional 2 January 9th, 2007 08:28 AM
Invalid postback or callback argument. kingw BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 January 1st, 2007 09:49 PM
Invalid Argument.... baNTON Access VBA 4 April 27th, 2004 06:18 AM

All times are GMT -4. The time now is 01:51 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.