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
Register
| 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 24th, 2006, 05:49 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in VBA script of Access

Hi
I have an Error in this code, maybe anyone can help!!!
THere is one error at rstFirstMove

Private Sub Form_Open(cancel As Integer)
Me.TimerInterval = 0
DoCmd.Maximize
Me.ScanIcon.Visible = False


    Dim db As Database
    Dim rst As Recordset
    Dim strQuery As String

    Set db c= DBEngine(0)(0)
    strQuery = "SELECT tbl_permission.PermissionID FROM tbl_permission WHERE (((tbl_permission.LoginName)=fOSUserName()));"
    Set rst = db.OpenRecordset(strQuery)
    rst.MoveFirst
    CurrentPermissionID = rst(0).value
    rst.Close


End Sub

Thanks a lot!!!

Julie

Reply With Quote
  #2 (permalink)  
Old January 24th, 2006, 06:47 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , , .
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is the query returning any values? If it is not that could be your problem. The solution would be to enclose the code there in the following:

If rs.bof AND rs.eof THEN
'empty recordset
Else
'insert code here
End If

Reply With Quote
  #3 (permalink)  
Old January 30th, 2006, 05:57 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

What exactly is fOSUserName? Is it a global string variable or a function of some kind? I suspect this line should look something like this...

strQuery = "SELECT [PermissionID] FROM tbl_permission WHERE [LoginName] = '" & fOSUserName() & "';"

If fOSUserName is a function or without the () if it's a variable.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #4 (permalink)  
Old January 30th, 2006, 05:58 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Oh, and you must assign fOSUserName a value if it's not a global variable that is not set elsewhere.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
Reply


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
Access controls, vba and arabic script tunsted Access VBA 0 January 17th, 2008 01:22 PM
DoCmd.GoToRecord Error in Access VBA myth12345 Access VBA 4 February 16th, 2006 01:58 AM
MS Access and VBA Error Diahann Access VBA 10 January 7th, 2005 05:46 PM
DoCmd.GoToRecord Error in Access VBA myth12345 Access VBA 1 October 30th, 2004 07:29 AM
DoCmd.GoToRecord Error in Access VBA myth12345 Access VBA 1 October 28th, 2004 10:27 AM



All times are GMT -4. The time now is 03:29 PM.


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