-
WSaral
AskWoody LoungerThank you very much for your replies.I have copied exactly the function but i obtain red letters on the following line:
If CLng(DLookup(“branch” & city, “Products”, strCondition)) < CLng(StrCartons) Then
which means i have some syntax problems, but i cannot find them.
I wonder why is it so, may be my Access does not include some references?
Here is how i copied the function:Public Function FncUpdateCartons()
Dim city As Long
city = Forms![FOrderInformation]![office] – 1
Dim MySubform As Form
Set MySubform = [Forms]![FOrderInformation]![Forder details extended].[Form]
Dim StrCartons As String
StrCartons = MySubform![cartons]
StrItems = MySubform![items]
Dim strSQL As String
Dim strWhere As String, strCondition As String
strCondition = "ProductID=" & MySubform.Productid
strWhere = " WHERE " & strCondition
strSQL = "UPDATE Products SET " & _
" products.branch" & city & " = products.branch" & city & " – " & StrCartons & "strWhere "
If CLng(DLookup("branch" & city, "Products", strCondition)) < CLng(StrCartons) Then
MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
Else
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL ' substract
End FunctionCould you please explain to me why do i receive line fo code coloured with red?
Very Best regards
-
WSaral
AskWoody LoungerThank you very much for your answer.Your first suggestion saved for me an amazing amount of coding,since i have to repeat the opton in many places.
In the second part, the whole line which isIf CLng(DLookup(“branch” & city, “Products”, strWhere)) < CLng(StrCartons) Then
MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
ElseSeems not to give some syntx error.Actually the error is the following:
Run time error 2075.
Syntax error(missing operator in query expression Where Productid = 76
Just to clarify. In my expreiment i wanted to update a product with id number 76.Here again is mny whole function:
Public Function FncUpdateCartons()
Dim city As Long
city = Forms![FOrderInformation]![office] – 1
Dim MySubform As Form
Set MySubform = [Forms]![FOrderInformation]![Forder details extended].[Form]
Dim StrCartons As String
StrCartons = [Forms]![FOrderInformation]![Forder details extended].[Form].[cartons]
StrItems = [Forms]![FOrderInformation]![Forder details extended].[Form].[items]
Dim strSQL As String
Dim strWhere As String
strWhere = " WHERE ProductID=" & MySubform.Productid
strSQL = "UPDATE Products SET " & _
" products.branch" & city & " = products.branch" & city & " – " & StrCartons & strWhere
If CLng(DLookup("branch" & city, "Products", strWhere)) < CLng(StrCartons) Then
MsgBox "There isn't enough stock to fill this order.", vbInformation + vbOKOnly
Else
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL ' substract
End FunctionI will be grateful if you point to me my syntax mistake,and also i must express my appreciation for your wonderful replies.
Best regards
-
WSaral
AskWoody LoungerDear Charlotte,
I habe followed the wonderful advices and have made anew the codes.I have now update statements where only the number of the branch is different, for example branch0 = Paris, branch1 = London etc.
If i have a function pointing to the number of the branch, then my update statement works, as in:Public Function FncUpdateCartons()
Dim city As Long
city = 1
strSQL = “UPDATE Products SET ” & _
” products.branch” & city & ” = products.branch” & city & ” – ” & StrCartons & strWhereetcetc
end function
Now i wanted to improve the function with the introduction of the enum as follows:
Public Enum GarudaCity
gcParis = 0
gcLondon = 1
gcRome = 2
End EnumAnd then i rearranged the function to read:
Public Function FncUpdateCartons( Optional city As GarudaCity)
strSQL = “UPDATE Products SET ” & _
” products.branch” & city & ” = products.branch” & city & ” – ” & StrCartons & strWhere
etc etc
End function
And then on the AfterUpdate event of the form i put :‘ call FncUpdateCartons (gcParis, Or gcLondon Or gcRome)
To my regret i receive no error, but no updating occurs.Coul you tell me why my Enum statement does not work?
-
WSaral
AskWoody LoungerI think you are right and my assumption that these two points are separate is wrong. By the way the answers i have received for the the invisible forms are excellent. But my question about the screen refers not only for forms but for all objects in the database.Actually, even though i have two different application the thread should be he same.please accept my inadverent mix up if the questions.
Also i must express my gratitude and appreciation for this forum since obviously i receive a good answer for everything i ask about Access. -
WSaral
AskWoody LoungerI owe you an apology. I didnt read your answer and just sent my second question, and aactualy you have answerdet that.I see i may be confusing with other threads.
So why do i need the code.The reason is i want to have a better comand on the actions.For example i want to change the messages, or to make the database close .
Best regards -
WSaral
AskWoody LoungerFurther to my question of today i have expreimented again and have tried to revise the code as follows
StrOrderDetails = ” SELECT[order details].ProductID.[order details].cartons,[orderdetails].quantity ” & _
” INTO [TempOrderDetails] FROM [order details] INNER JOIN orders ON [order details].OrderID = [orders].orderid WHERE [orders].orderid = ” & Me.OrderIDNow i receive the error “Too few parameters.Expected2.Why is it so?
Please help -
WSaral
AskWoody LoungerThank you very much for your kind attention! Please help me further please.It is so important to me.
I have followd your advices as far as i can.I receive now the message ” Join expression not supported”
Here is the code that i have now, after i have made the order, in the OnClick event of the form:Dim StrOrders As String
Dim StrOrderDetails As StringStrOrders = “SELECT orders.orderid, orders.customerid, orders.orderdate, orders.[required date], orders.paymentid, orders.PaymentMethodID, orders.bankid,
orders.invoicedate, orders.AuftragNr ” & _
” INTO Temp FROM orders WHERE orderid = ” & Me.OrderIDStrOrderDetails = ” SELECT[order details].ProductID.[order details].cartons,[orderdetails].quantity ” & _
” INTO [TempOrderDetails] FROM [order details] INNER JOIN orders ON [order details].OrderID = [order details].orderid WHERE orderid = ” & Me.OrderIDCurrentDb.Execute StrOrders
CurrentDb.Execute StrOrderDetailsThe execution of StrOrders is perfect.I receive a temporary table called Temp containing only the order i have issued and it does the job.
But the execution of StrOrderDetails fails.Then i receive the message “Join expression not supported”.
I will be so grateful as always for the help.P.S. In order to help me please note that the ProductID comes from the related table Products, where the ProductId is conected with the table
Order Details in one to many relationships. Therefore the productid is availabe in the subform and not in the mainform.These are only mine considerations butsince i am not a proffessional programmer i am surely on the wrong path.All i want is to have a temporry table containing all the details for a given order,as the
number of the product, cartons and quantity, the same as i have already a table containig only this given order.I cannot explain myself why in the first case i
receive the table i want but not in the second case.
-
WSaral
AskWoody LoungerThank you for your reply. If you disregard the end use of my cod because i will bother you with my lenfgthy explanation,, could you show me what is wrong with my code? When i debug it it shows “Type mismatch”. It think i am committing some grave mistake somewhere.
it is as followsDim StrPassword As String
StrPassword = “secret”
Dim db As DAO.Database
Set db = DBEngine.Workspaces(0).OpenDatabase(CurrentDb, dbDriverComplete, False, “; PWD=” & StrPassword)Bes Regards !
-
WSaral
AskWoody LoungerA perfect answer. I feel obliged to express my gratitude since this was so important to me.
Thank you very much ! -
WSaral
AskWoody Loungerthank you for your reply.I am trying to get data out of the protected on into the unprotected database.I agrre with what you write about the protection it is just a special case where i need it and if you are interested i may send the explanation to you,however i am afraid i may be boring.How shall i proceed in my case to get data out of the protected database?
Kind regards
-
WSaral
AskWoody LoungerCan i have a help with an Update query? I want to update the fields paymentid,bankid,invoicedate and Paymentmethodid
from the table orders to be equal to the same fields in the table orders1.In other words, i want to insert the values from the table orders1 into the table orders.The values in the table orders are in fact old values and the values in the table orders1 are the new values.
I am confused about the expressions Insert Into and Update and i cannot handle the wizard.
Below are the two select clauses,just for orientation.SELECT orders.paymentid, orders.bankid, orders.invoicedate, orders.PaymentMethodID
FROM orders;SELECT orders1.paymentid, orders1.bankid, orders1.invoicedate, orders1.PaymentMethodID
FROM orders1;I suppose the code shoud read
Update orders ( or orders1? i am not sure) .paymentid SET orders.paymentid = orders1.paymentid, orders1.bankid = orders1.bankidbut what i write did not make sense to me.Shall i write InsertInto instead of Update?
-
WSaral
AskWoody LoungerThank you very much for your reply. Could you help me further? I receive an error “missing operator in query expression “when
i use the concatenated strBerlin.I cannot find out the origin of my error.I do have a control named site in my form, also in my report.
Without the strBerlin the function works.
Bedlow is my function :Public Function FncSites()
‘ Defines the StrCriteria on opening the report.
Dim f As Form
Set f = Forms!Orders
f.Visible = False
Dim strDocName As String
Dim strCriteria As String
Dim OrderDate As Control
‘set the months
Dim jan As String
‘set the months
Dim month As Control
‘naming of variables
Set OrderDate = Forms!Orders![OrderDate]
Set month = Forms!Orders![month]
Set month = Forms!Orders![month]
jan = “Month(Orderdate)= 1 and year(Orderdate) = ” & CnstYear
Select Case month
Case 1
strCriteria = jan
End Select
strDocName = ” rptSalespersite”Dim strBerlin As String
strBerlin = “(” & Forms!Orders![site] & ” 8000)”DoCmd.OpenReport strDocName, acPreview, , strCriteria & ” AND ” & strBerlin
Forms![Orders]![month].Value = 0
End FunctionI will appreciate very much your help
-
WSaral
AskWoody LoungerExcellent. Thats what i meant and your suggestions are very useful
-
WSaral
AskWoody LoungerThank you so much for your wish to help.I think you will be able to help me if I send to you my abridged database.In short, the autoexec macro runs a code that opens a form and in the OnOpen event of the form is my function.I have simplified it so that the function, for more clarity, contains only the command DoCmd.Beep. So what I want is that aftewr performing the function, in this case DoCmd.Beep, to quit the application and close the database.But at the end I receive the message
-
WSaral
AskWoody Loungeri feel obliged to thank you for your nice and elegant answer
Regards
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Where’s the cache today?
by
Up2you2
41 minutes ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 hours, 21 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
2 hours, 41 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
7 hours, 22 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
12 hours, 29 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
12 hours, 36 minutes ago -
regarding april update and may update
by
heybengbeng
14 hours, 5 minutes ago -
MS Passkey
by
pmruzicka
1 hour, 53 minutes ago -
Can’t make Opera my default browser
by
bmeacham
21 hours, 45 minutes ago -
*Some settings are managed by your organization
by
rlowe44
8 hours, 28 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
20 hours, 40 minutes ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
1 day, 16 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
2 days, 1 hour ago -
AI slop
by
Susan Bradley
15 hours, 27 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
2 days, 2 hours ago -
Two blank icons
by
CR2
14 hours, 22 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 11 hours ago -
End of 10
by
Alex5723
2 days, 14 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 12 hours ago -
test post
by
gtd12345
2 days, 20 hours ago -
Privacy and the Real ID
by
Susan Bradley
2 days, 10 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
12 hours, 42 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
3 days ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 12 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 15 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
3 days, 16 hours ago -
The story of Windows Longhorn
by
Cybertooth
3 days, 3 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
3 days, 18 hours ago -
Are manuals extinct?
by
Susan Bradley
18 hours, 34 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
4 days, 3 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.