you need to modify the current query to add a criteria:
SELECT * FROM yourTable WHERE fncLog();
supposed that you want to Log it on tblLog:
fields:
QueryName (short string)
Last Run (Date/time)
create a function that will return a boolean (true):
Public Function fncLog() As Boolean CurrentDb.Execute "insert into tblLog(QueryName, [Last Run]) " & _ "select '" & CurrentObjectName & "',#" & Now() & "#" fncLog = True End Function
you need to modify the current query to add a criteria:
SELECT * FROM yourTable WHERE fncLog();
Thanks so where will this function sit?Ok thanks so i have created the Module and you say add this to my current query
"SELECT * FROM yourTable WHERE fncLog();"
So the query is updating a table of data so how would i call the fnclog?
Last edited: Oct 18, 2020See my VBA Beginner blog:-
www.niftyaccess.com
There are video instructions on how to create a command button and also demonstrats how the command button has an onclick event which I assume is where you would want to call your query from.
cant run the function i think as the query is an append query
Where do you call the query from? In other words which event calls the query?
Do you press a button? do you load a form? Does it run when MS Access opens?
Where do you call the query from? In other words which event calls the query?
Do you press a button? do you load a form? Does it run when MS Access opens?
yeah i have a button on a form that runs the queryThanks worked by the name captured is the Form Name and not the 3 queries them self that got ran when the button was clicked
Last edited: Oct 18, 2020so i change the code in the fucntion to set the query name and it all works now
supposed that you want to Log it on tblLog:
fields:
QueryName (short string)
Last Run (Date/time)
create a function that will return a boolean (true):
Public Function fncLog() As Boolean CurrentDb.Execute "insert into tblLog(QueryName, [Last Run]) " & _ "select '" & CurrentObjectName & "',#" & Now() & "#" fncLog = True End Function
you need to modify the current query to add a criteria:
SELECT * FROM yourTable WHERE fncLog();
this was working fine, but now we are in november its recording the date formating as US, i have the table set with the format as "dd/mm/yyyy hh:mm"- but the date and time today is show as "11/02/2020 08:31" . do i need to change the code?