Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2006, 05:49 PM
Registered User
 
Join Date: Jan 2006
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

 
Old January 24th, 2006, 06:47 PM
Friend of Wrox
 
Join Date: Dec 2005
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

 
Old January 30th, 2006, 05:57 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old January 30th, 2006, 05:58 PM
Friend of Wrox
 
Join Date: Jun 2003
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





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





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