Hi all,
Hoping someone might be able to point me in the right direction with getting the code below to work properly.
Effectively, the code: - Requerys the listbox in lstPrintCheckedStaff
- Selects all the items rows in lstPrintCheckedStaff
Then for each row in the list box: - Calls a msgbox to confirm if an e-mail should be sent to that person. (Yes / No)
- If yes, sends an e-mail and records that in the table AuditLog
The problem I have is with the very last bit - recording to the Audit Log and specifically the Name (obtained from lstPrintCheckedStaff.Column(1) and lstPrintCheckedStaff.Column(3). When running the code it works fine (and sends the e-mail), but presents me with error 3085 "Undefined function 'lstPrintCheckedStaff.Column' in expression" every time. I've tried loads of different ways I can think of (including "Dim"ing it first, but it jsut requests the parameter value then...
Any suggestions/assistance greatly apprecicated!
Cheers,
Will - Private Sub cmdIssueEmailNotifications_Click()
-
On Error GoTo ErrorHandler
-
-
Forms!frmEditPrePayment!lstPrintCheckedStaff.Requery
-
Call ListBoxSelectAll(Forms!frmEditPrePayment!lstPrintCheckedStaff)
-
-
Dim varItemCheckedStaff As Variant
-
Dim varItemCheckedStaffName As Variant
-
Dim varItemCheckedStaffUsername As Variant
-
-
For Each varItemCheckedStaff In Me.lstPrintCheckedStaff.ItemsSelected
-
varItemCheckedStaffName = Me.lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & Me.lstPrintCheckedStaff.Column(2, varItemCheckedStaff)
-
-
Dim mbxResponse As VbMsgBoxResult
-
mbxResponse = MsgBox( _
-
"Do you want to send an e-mail to " & varItemCheckedStaffName & "?", _
-
vbQuestion + vbYesNo, TSM_APPLICATION_STANDARDCAPTION & "Send an e-mail...")
-
-
If mbxResponse = vbYes Then
-
-
Dim oApp As Object, oAcct As Object
-
Dim oMessages As Object, oMessage As Object
-
Dim ToYou As String, TheSubject As String
-
-
varItemCheckedStaffUsername = Me.lstPrintCheckedStaff.Column(4, varItemCheckedStaff)
-
-
ToYou = varItemCheckedStaffUsername 'Issue mailbox
-
TheSubject = "A QMS Feedback Sheet has been sent to your DIP tray"
-
-
Set oApp = CreateObject("NovellGroupWareSession")
-
Set oAcct = oApp.login("", "")
-
Set oMessages = oAcct.mailbox.messages
-
Set oMessage = oMessages.Add()
-
oMessage.Priority = 2
-
oMessage.Recipients.Add ToYou
-
oMessage.Subject = TheSubject
-
oMessage.Send
-
-
Dim strAuditLogUser As String
-
strAuditLogUser = txtUserID.Value
-
Dim strAuditLogComputer As String
-
strAuditLogComputer = txtComputerID.Value
-
Dim strEntryID As String
-
strEntryID = txtEntryID.Value
-
Dim strAuditLogForm As String
-
strAuditLogForm = Form.Name
-
Dim strAuditLogVBA As String
-
strAuditLogVBA = "cmdIssueEmailNotifications_Click"
-
Dim strAuditLogAction As String
-
strAuditLogAction = "Issued e-mail notification to " & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & lstPrintCheckedStaff.Column(2, varItemCheckedStaff)
-
-
DoCmd.SetWarnings (False)
-
Rem CurrentDb.Execute ("INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction])VALUES (strEntryID, strAuditLogUser, strAuditLogComputer, strAuditLogForm, strAuditLogVBA, strAuditLogAction)")
-
DoCmd.RunSQL ("INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to ' & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & ' ' & lstPrintCheckedStaff.Column(2, varItemCheckedStaff))")
-
DoCmd.SetWarnings (True)
-
-
End If
-
-
Next
-
-
Exit_cmdIssueEmailNotifications_Click:
-
DoCmd.SetWarnings (True)
-
Exit Sub
-
-
ErrorHandler:
-
Beep
-
Call MsgBox("An error was encountered. Please try again." & vbCrLf & _
-
vbCrLf & _
-
"If the problem persists, please contact " & TSM_APPLICATION_SYSTEMADMIN & " quoting:" & vbCrLf & _
-
" Error code: " & Err.Number & vbCrLf & _
-
" Description: " & Err.Description, vbCritical, TSM_APPLICATION_ERRORCAPTION)
-
Resume Exit_cmdIssueEmailNotifications_Click
-
End Sub
Hi
Yes I know the problem (I think!), and I thought I had suggested an answer, but if you insist on using your current code, then try repacing this - DoCmd.RunSQL ("INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to ' & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & ' ' & lstPrintCheckedStaff.Column(2, varItemCheckedStaff))")
with this - DoCmd.RunSQL "INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to " & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & lstPrintCheckedStaff.Column(2, varItemCheckedStaff) & "')"
I is a bit difficult to 100% sure the syntax is correct without having the code in the correct environment to compile, but I think it is OK!?
MTB
4 2046
Hi
I'm just gesing here but I think perhaps you should go back to you first(?) thoughts but change this - strAuditLogAction = "Issued e-mail notification to " & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & lstPrintCheckedStaff.Column(2, varItemCheckedStaff)
-
to this - strAuditLogAction = "'Issued e-mail notification to " & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & lstPrintCheckedStaff.Column(2, varItemCheckedStaff) & "'"
ie. put apostrophes in the string ??
In you current code you are confusing the us of these ' with these " and hence confusing the compiler!
MTB
Hi Mike,
Thanks for replying... really appreciate it.
Unfortunately, that doesn't resolve it. I've run through the code using Debug > Step Into and the error occours on this line of code: - DoCmd.RunSQL ("INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to ' & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & ' ' & lstPrintCheckedStaff.Column(2, varItemCheckedStaff))")
If I take out: - & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & ' ' & lstPrintCheckedStaff.Column(2, varItemCheckedStaff)
it runs fine. I can't see any " or ' errors and it still doesn't work if I take out all of the text from the last parameter and just leave - lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & lstPrintCheckedStaff.Column(2, varItemCheckedStaff)
Really stumped! Any further thoughts are greatly appreciated!
Thanks again for taking to time to post.
Will
Hi
Yes I know the problem (I think!), and I thought I had suggested an answer, but if you insist on using your current code, then try repacing this - DoCmd.RunSQL ("INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to ' & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & ' ' & lstPrintCheckedStaff.Column(2, varItemCheckedStaff))")
with this - DoCmd.RunSQL "INSERT INTO AuditLog ([EntryID], [AuditLogUser], [AuditLogComputer], [AuditLogForm], [AuditLogVBA], [AuditLogAction]) VALUES (txtEntryID.Value, txtUserID.Value, txtComputerID.Value, Form.Name, 'cmdClose_Click', 'Issued e-mail notification to " & lstPrintCheckedStaff.Column(1, varItemCheckedStaff) & " " & lstPrintCheckedStaff.Column(2, varItemCheckedStaff) & "')"
I is a bit difficult to 100% sure the syntax is correct without having the code in the correct environment to compile, but I think it is OK!?
MTB
Yeah!!!
It worked!
Thank you ever so much... really appreciate it!
Cheers,
Will
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ronald W. Roberts |
last post by:
I'm not sure where this routine came from,
but here is the problem. On certian computers
this error occurs, but it does not on others.
The error is: "Undefined Function "DIR" in expression".
...
|
by: paddy_nyr |
last post by:
I converted an Access 97 db to Access 2002 db and I now get the following
error message when I try and run a query.
Thanks
Here's my query.
SELECT DISTINCTROW tblCo_Info.Co_id, & Chr(13) &...
|
by: carrionk |
last post by:
Hi,
I'm running an ADO Recorset from Excel to gather data from Access.
Basically it's copying the records of a query -that runs without
problem in Access-
That query has an expression with NZ()...
|
by: sam.s.kong |
last post by:
Hello!
I have a very basic question.
a.c:
<code>
#include <stdio.h>
main()
|
by: alanwo |
last post by:
Hi Experts,
Connected to Access MDB file using ADO.net OLEDB, I have a SQL to get
file extension from file name which is stored as field.
SELECT Right(FileName, Len(FileName) -...
|
by: Wade |
last post by:
My query contains a field called TotalIn, which returns number data from an underlying table. I have modified a function, PrevRecVal, which returns the datum form the previous record in the TotalIn...
|
by: MLH |
last post by:
I got this error twice in 72-hours.
Each time, a different global procedure
was not found. One was being used
in an SQL statement and the other in
a Set stmt in DAO routine.
Both FNs, of...
|
by: patjones |
last post by:
Good morning all:
In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending...
|
by: CCHDGeek |
last post by:
I created a database with a separate front-end that is installed on each computer and linked to a back-end server. After installing the file on several computers, I realized I was getting this...
|
by: Sebastian |
last post by:
Hello
I develop my applications in Access 2002. My development system is
running Windows XP SP2 and I have Microsoft Office XP Developer.
Microsoft Office XP is at SP3.
I used Inno Setup (great...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |