auto populate table fields (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
Yes using CurrentDb.Execute in VBA as I suggested. It only affects that line of code.
Alternatively you can use DoCmd.SetWarnings False before the query in VBA and DoCmd.SetWarnings True afterwards...but that will suppress all messages including error messages.
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
Yes using CurrentDb.Execute in VBA as I suggested. It only affects that line of code.
Alternatively you can use DoCmd.SetWarnings False before the query in VBA and DoCmd.SetWarnings True afterwards...but that will suppress all messages including error messages.

where to put the VBA code to affect this query?
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
Where/when do you want it to run?
Possibly on a form load event or a button click event?
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
Where/when do you want it to run?
Possibly on a form load event or a button click event?

i made the form of revenue to run the query as an after update, so after each insertion of the payment the sales table updated accordingly, But i keep seeing the warning message.

where do you suggest to add the VBA code in order to suppress these messages?
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
Are you running this as a saved query from code or running the SQL statement posted earlier?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:20
Joined
Oct 29, 2018
Messages
21,485
i made the form of revenue to run the query as an after update, so after each insertion of the payment the sales table updated accordingly, But i keep seeing the warning message.

where do you suggest to add the VBA code in order to suppress these messages?
How exactly did you make the form to "run" the query? That's where you would put the additional code.
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
How exactly did you make the form to "run" the query? That's where you would put the additional code.

the query opened by macro, and the code is VBA

how to add both of them??
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
I'm sorry but that makes no sense at all.
Please show a screenshot and/or post the full code used
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
I'm sorry but that makes no sense at all.
Please show a screenshot and/or post the full code used

This is the code used to make the job done

UPDATE Sales INNER JOIN Revenues ON (Sales.[Customer]=Revenues.[Customer]) AND (Sales.[Date]=Revenues.[Invioce Date]) SET Sales.[Paid On] = Revenues.[Payment Date]
WHERE Sales.[Paid On] Is Null;
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
I suggest the following

Code:
Private Sub YourControlName_AfterUpdate()

Dim strSql as string

Strsql = "your code from the last post here"
CurrentDb.Execute strSql, dbFailOnError

Note that there is no macro involved using that approach
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
I suggest the following

Code:
Private Sub YourControlName_AfterUpdate()

Dim strSql as string

Strsql = "your code from the last post here"
CurrentDb.Execute strSql, dbFailOnError

Note that there is no macro involved using that approach

sorry
would you please tell me where to put this CODE??
should i add in place my code?
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
Add it as an event procedure of whatever control you are updating.
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
Add it as an event procedure of whatever control you are updating.

is this code right

Private Sub Form_AfterUpdate()
Private Sub YourControlName_AfterUpdate()

Dim strSql As String

strSql = "UPDATE Sales INNER JOIN Revenues ON (Sales.[Customer]=Revenues.[Customer]) AND (Sales.[Date]=Revenues.[Invioce Date]) SET Sales.[Paid On] = Revenues.[Payment Date]"
WHERE Sales.[Paid On] Is Null;"
CurrentDb.Execute strSql, dbFailOnError
End Sub

as ive got error message from visual basic window
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:20
Joined
Oct 29, 2018
Messages
21,485
i did tried to SetWarnings to No But still the messages showing

Hi. I'm sure you'll get it to work eventually, but could you please post a screenshot of your macro showing how you tried to use the SetWarnings action? I'm just curious...
 

isladogs

MVP / VIP
Local time
Today, 14:20
Joined
Jan 14, 2017
Messages
18,246
Umm...no.
Scrap the Form_AfterUpdate line
Replace the 'yourcontrolname' in the next line with the actual name of the control being updated

Note that I'm giving you instructions for an event procedure.
DBG is advising you about a macro solution.
Do one or other but not both
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
Umm...no.
Scrap the Form_AfterUpdate line
Replace the 'yourcontrolname' in the next line with the actual name of the control being updated

Note that I'm giving you instructions for an event procedure.
DBG is advising you about a macro solution.
Do one or other but not both

what do you mean by control?? the table??
and i know that i should choose either one
 

ElPerson

Registered User.
Local time
Today, 16:20
Joined
May 27, 2019
Messages
27
Hi. I'm sure you'll get it to work eventually, but could you please post a screenshot of your macro showing how you tried to use the SetWarnings action? I'm just curious...

i deleted it right now and working on the VBA way

i'll reply later with a screen shot

Thak you
 

Users who are viewing this thread

Top Bottom