473,699 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB Functions Dont Work with Workgroup Security


I have several VBA functions in my Access Database that do not work.

I have a combobox that filters my subform data however I cannot select
anything when logged in with Read Only permission.

The statusbar comes up with a message saying:
"Recordset is not updatable"

This combobox works with Admin permissions but not Read Only.

Secondly I have a VBA function that does not work even with admin
permissions. It uses the following connection string:

strConnectionSt ring = Application.Cur rentProject.Acc essConnection

I have a feeling this connection string is invalid when security has
been implemented so i guess the question is, is there a function I can
use to bypass security from a coding level or is there a way where I
can hardcode admin username and password for any VBA code.

Thanks in advance!

Aug 31 '06 #1
1 1595
Sorry the answer was so obvious and I totally missed it (I was
wondering why it worked on one form but not the other but then I
realised I was using a list box for the other form). Sorry my bad!

As for the code:
What the code does is, everytime a change is made on a form, the change
is recorded with details of the username and date recorded as well.
This information is then transferred into an audit table.
The following code captures the PK and passes into the Audit trail
function:

Private Sub Form_BeforeUpda te(Cancel As Integer)
'if Billing Element Details are edited, then capture Audit data
If Not IsNull(Me![Element ID]) And Me![Element ID] <"" Then
AuditTrail "Element Id", Me![Element ID],
Form_Subfrm_Bil ling_Single
End If
End Sub

Below is the Audit Trail function

Option Compare Database
Option Explicit
Public strConnectionSt ring As String

Public Sub AuditTrail(KeyF ieldName As String, KeyFieldValue As String,
MyForm As Form)
'Procedure Name - AuditTrail
'Description - This procedure captures the amendments done in
each and every fields of the Products, Hierarchy, Rules, Kenan, Seibel
tables
'Parameters - KeyFieldName - Name of the Key Field that
uniquely identifies the modified record
' - KeyFieldValue - Value of the Key Field that uniquely identifies
the modified record
' - MyForm - Form Object that holds the reference to the Form in
which the amendments are made

On Error GoTo Err_Handler
Dim objConn As New ADODB.Connectio n
Dim strSql As String
Dim c As Control, xName As String
strSql = ""

'Connection string for Product Definition Database

strConnectionSt ring = Application.Cur rentProject.Acc essConnection

'Set date and current user if form has been updated.
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
"Changes made on " & Date & " at - " & Time & " by " &
CurrentUser() & ";"

'If new record, record it in audit trail and exit sub.
If MyForm.NewRecor d = True Then
If Not IsNull(MyForm!U pdates) And MyForm!Updates <"" Then
'New Record is not yet captured in Audit
MyForm!Version = 1
Dim strAddition As String ' to capture Addition details
If Left(KeyFieldNa me, 7) = "Element" Then
If MyForm.Name = "SubFrm_Hierarc hy_Element" Then
'New Element Addition
strAddition = "New Element - " & KeyFieldValue & "
added for Product - " & MyForm![Product]
Else
Exit Sub
End If
Else
'New Product Addition
strAddition = "New Product - " & KeyFieldValue & "
added "
End If
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) &
strAddition
'Inserting Audit Information for the New Record
objConn.Connect ionString = strConnectionSt ring
On Error GoTo DBAccess_Err
objConn.Open
strSql = "INSERT INTO TBL_AUDIT ([USER NAME], [CHANGE
DATE], [TABLE NAME]," _
& " [KEY FIELD NAME], [KEY FIELD VALUE], [FIELD
CHANGED],CHANGES)" _
& " Values ('" & CurrentUser() & "' ,#" _
& Format(Date, "dd-MMM-yyyy") & " " & Format(Time,
"hh:mm:ss AMPM") & "# , '" & MyForm.RecordSo urce & "' ,'" _
& KeyFieldName & "','" & KeyFieldValue & "','','" _
& strAddition & "')"
On Error GoTo QueryExecErr
objConn.Execute strSql
objConn.Close
End If
Else
'if record is Edited, capture Audit Trail Data
Dim strOldValue As String 'To store the Old Value of the form
control
Dim bolInsert As Boolean 'Boolean value to check whether the
Audit log need to be inserted or not
Dim intAuditCount As Integer
intAuditCount = 0
'Check each data entry control for change and record old value
of Control.
For Each c In MyForm.Controls
'Only check data entry type controls.
Select Case c.ControlType
Case acTextBox, acComboBox, acOptionGroup
bolInsert = False
strOldValue = ""
' Skip Updates field and Version Field
If c.Name <"Updates" And c.Name <"Version" Then
' If control was previously Null, record "previous
' value was blank."
If (IsNull(c.OldVa lue) Or c.OldValue = "") Then
'check if some value has been inserted in
the blank field
'if so, record it in Audit Trail
If (Not IsNull(c.value) Or c.value <"")
Then
MyForm!Updates = MyForm!Updates &
Chr(13) & _
Chr(10) & c.Name & " -- previous value
was blank"
strOldValue = "Blank "
bolInsert = True
End If
' If control had previous value, record
previous value.
' and it has been changed now, record it in
Audit Trail
ElseIf IIf(IsNull(c.va lue), "", c.value) <>
c.OldValue Then
strOldValue = c.OldValue
MyForm!Updates = MyForm!Updates & Chr(13) &
Chr(10) & _
c.Name & " == previous value was " &
c.OldValue
bolInsert = True
End If

If bolInsert = True Then
objConn.Connect ionString =
strConnectionSt ring
On Error GoTo DBAccess_Err
objConn.Open
'Inserting Change details in AuditTrail
table
strSql = "INSERT INTO TBL_AUDIT ([USER
NAME], [CHANGE DATE], [TABLE NAME]," _
& " [KEY FIELD NAME], [KEY FIELD VALUE],
[FIELD CHANGED],CHANGES)" _
& " Values ('" & CurrentUser() & "'
,#" _
& Format(Date, "dd-MMM-yyyy") & " "
& Format(Time, "hh:mm:ss AMPM") & "# , '" & MyForm.RecordSo urce & "'
,'" _
& KeyFieldName & "','" &
KeyFieldValue & "','" _
& c.Name & "' , '" & strOldValue &
" --" _
& c.value & "')"
On Error GoTo QueryExecErr
objConn.Execute strSql
objConn.Close
intAuditCount = intAuditCount + 1
End If
End If
End Select
Next c
If intAuditCount 0 Then
'Edit case, so increment the Version of the changes
MyForm!Version = MyForm!Version + 1
End If
End If
Set objConn = Nothing

TryNextC:
Exit Sub

DBAccess_Err:
MsgBox "Error Occured while Conencting to the Database." & vbCrLf &
Err.Description , vbCritical, "Audit Module"
Exit Sub
QueryExecErr:
MsgBox "Error occured while Inserting data in to Audit Trail" &
vbCrLf & Err.Description , vbCritical, "Audit Module"
Resume Next
Err_Handler:
If Err.Number <64535 Then
MsgBox "Error occured while caoturing Audit Data " & vbCrLf &
"Descriptio n: " & Err.Description , vbCritical, "Audit Module"
End If
Resume TryNextC
End Sub
I hope this provides enough info to get a better understanding of my
problem.
Thanks!

Aug 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10091
by: Newbillian | last post by:
Is there some way of using vba to automate the processe of joining an Access 97 security workgroup? I typed wrkgadm /? at a command prompt and it just opens the gui, so I'm not sure what the parameters are for the command or whether there really are any command line switches for it. Thank you in advance.
1
1795
by: Daniel | last post by:
Thank you for reading... I have developed two separate dbases using Access 2002. Each has their own workgroup specifications. On each users desktop I created a shortcut to the front end dbase and with the appropriate workgroup: Path of shortcut is: "locationofMSACCESS.EXE" "locationoffrontend.mdb" /wrkgrp "locationofworkgroup.mdw"
4
1506
by: Chris Tyson | last post by:
My problem is this: I have created a database, using Workgroup security features. Unique Workgroup. New users added. Permissions to Admins, Admin, and Users revoked. 'Ownership' of database objects has been given to a custom User, and has not been left as owned by Admins. I transfer this file (and its Workgroup) to a shared drive on a LAN. From the original client PC that originated the file, the database cannot be opened without...
1
2352
by: Dom | last post by:
Hi, I have a problem in getting Access 2002 to read my workgroup file. I've created different groups and users and when the db is opened the user is prompted to enter a username and password which seems to be working perfectly on my PC. However, when someone else on a different computer opens this db on the shared network the user is no longer asked to enter their username and password and they are logged on as the default admin user.
1
2530
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my system login. Can this be done? Thanks
1
1674
by: paulsmith5 | last post by:
Hi, I secured a database a while back using the User-Level Security Wizard. During this process I created a new workgroup file, modified the Admins group by adding a new administrator and removing the original Admin account etc. Users opened up the database using a shortcut which pointed to the new workgroup file. Everything worked out fine. Now I wish to create a new database, with new database objects and apply the same security to...
3
4302
by: JaBo | last post by:
Our company computers were recently upgraded to Windows XP with Microsoft Office 2003. We have 3 different Access Databases (in different directories on our network) which all require the user to be part of a "Workgroup". It appears that Access 2003 includes some added security features that prevent the user from accessing a database unless you join the workgroup corresponding to the database. This works fine, unless you need to join...
2
4825
by: dogman_2000 | last post by:
Hi All I am new to working with Access workgroup files and have a question. I joined a new access workgroup (one which was already created by a previous access developer) via the access Tools - Security - Workgroup Administrator option. Now I get the log on screen for every access db I open.
4
10884
by: duffaz | last post by:
I am trying to I am trying to connect to an SQL Server using a vb.net program. It works if I put it on the SQL Server computer, but will not connect over my local network that is set up as a workgroup. I get the following message: Login failed for user 'DELL4100\Guest' DELL4100 is the computer name where the sql server is on. The connection string is: Data Source=dell4100;Database=dbname;User ID=dbn;Password=password; I have also...
0
8691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7755
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2351
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.