|
 |
access thread: user ID
Message #1 by "Nikola" <Nikola@b...> on Tue, 22 Oct 2002 10:18:58 +0100
|
|
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error ?424? ? Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #2 by "Carnley, Dave" <dcarnley@a...> on Tue, 22 Oct 2002 09:34:47 -0500
|
|
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #3 by "Nikola" <Nikola@b...> on Tue, 22 Oct 2002 18:41:26 +0100
|
|
no i get same error message
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 15:35
To: Access
Subject: [access] user ID
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #4 by "Carnley, Dave" <dcarnley@a...> on Tue, 22 Oct 2002 11:15:33 -0500
|
|
which line of code does the debugger indicate is causing the error?
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 12:41 PM
To: Access
Subject: [access] RE: user ID
no i get same error message
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 15:35
To: Access
Subject: [access] user ID
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #5 by "Nikola" <Nikola@b...> on Tue, 22 Oct 2002 19:31:10 +0100
|
|
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName() <--- This line
End If
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 17:16
To: Access
Subject: [access] RE: user ID
which line of code does the debugger indicate is causing the error?
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 12:41 PM
To: Access
Subject: [access] RE: user ID
no i get same error message
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 15:35
To: Access
Subject: [access] user ID
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #6 by "Carnley, Dave" <dcarnley@a...> on Tue, 22 Oct 2002 11:59:52 -0500
|
|
When I set a value into a combobox I just use me.cboWhatever = NewValue. It
defaults to the bound column.
The object browser in my Access project lists 2 classes for ComboBox, one
belongs to Access and one belongs to MSForms. The Access version lists
property Column(index) as read-only however the MSForms one does not.
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 1:31 PM
To: Access
Subject: [access] RE: user ID
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName() <--- This line
End If
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 17:16
To: Access
Subject: [access] RE: user ID
which line of code does the debugger indicate is causing the error?
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 12:41 PM
To: Access
Subject: [access] RE: user ID
no i get same error message
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 15:35
To: Access
Subject: [access] user ID
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
Message #7 by "Nikola" <Nikola@b...> on Wed, 23 Oct 2002 11:05:24 +0100
|
|
Hi Dave ,
I found Solution
On my form i create text field and source is :
=DLookUp("[employeeid]","Employees","UserName = '" & ap_GetUserName() & "'")
and code in Edit button is :
Private Sub cmdEditMode_Click()
If Me.EmployeeID.Column(1) <> ap_GetUserName() Then
Me.EmployeeID = txtUsername
End If
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
Q : is this correct way or is same another approach ?
Thanks
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 18:00
To: Access
Subject: [access] RE: user ID
When I set a value into a combobox I just use me.cboWhatever = NewValue. It
defaults to the bound column.
The object browser in my Access project lists 2 classes for ComboBox, one
belongs to Access and one belongs to MSForms. The Access version lists
property Column(index) as read-only however the MSForms one does not.
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 1:31 PM
To: Access
Subject: [access] RE: user ID
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName() <--- This line
End If
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 17:16
To: Access
Subject: [access] RE: user ID
which line of code does the debugger indicate is causing the error?
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 12:41 PM
To: Access
Subject: [access] RE: user ID
no i get same error message
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Tuesday October 2002 15:35
To: Access
Subject: [access] user ID
I think you have a syntax error
Me.EmployeeID.Column(1) = ap_GetUserName
should be
Me.EmployeeID.Column(1) = ap_GetUserName()
since ap_GetUsername() is being used as a function to return a value, VB
wants the parentheses. If no value is returning, you can leave them off...
I think this is correct ;)
-----Original Message-----
From: Nikola [mailto:Nikola@b...]
Sent: Tuesday, October 22, 2002 4:19 AM
To: Access
Subject: [access] user ID
Hi all,
I have this two code :
First is module:
---------------- start ---------------------------
Option Compare Database
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant
Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255
'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)
'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)
End Function
----------------------------- END -----------------------------
Second one is in Switch board and on open event a have Call Validate User
------------------ Start ---------------------------------------
Public Function ValidateUser()
'Confirm that the user should be able to enter this database
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Username FROM Employees WHERE
username = """ & UCase(ap_GetUserName) & """;")
'Check to see if the user name is in the list of valid users
If rst.EOF Then
MsgBox "You are not authorized to use this database!" & vbNewLine &
_
"Please contact the IT Department for permission.", _
vbCritical, "No Authorization"
rst.Close
Set rst = Nothing
Set db = Nothing
Application.Quit
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
All this is working ok but I have problem . Before in form Order I have
combobox EmployeesID so user found his name and selected so in table orders
for each order I have Employer ID (what is Number).But now on same form I
have Edit button so if same one open record and hi want to make same
changes hi need to press edit button
So on click event is this code :
Private Sub cmdEditMode_Click()
Me.EmployeeID.Column(1) = ap_GetUserName
With Me
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
Me.cmdEditMode.Caption = "Edit Mode On"
End Sub
But I get run time error '424' - Object required
And Query for emploee Combobox is :
SELECT DISTINCTROW Employees.EmployeeID, Employees.UserName, [LastName] & "
" & [FirstName] AS Name
FROM Employees
ORDER BY Employees.LastName, Employees.FirstName;
Thanks for any help
|
|
 |