-
WSaral
AskWoody LoungerThank you for your reply.I do not get any error,but the tables orders and order details are not linked in one to many relationship when i check it..I am puzzled since with the other function it works and i can see the links created.But in this case no error occrus but nothing is created
Best regards
-
WSaral
AskWoody LoungerThank you very much for your reply.Could you please check up what i have done, since i am afraid i do make some errors in my
code and i receive the message ” syntax error in query expression orderdate< #1/1/2002# "Public Const CnstBefore As Date = #1/1/2002#
Public Function Test()
Dim SqlRemoveFromOrders
SqlRemoveFromOrders = "DELETE DISTINCTROW orderdate FROM orders WHERE orderdate < #" & Format(CnstBefore, "mm/dd/yyyy") & "#"
CurrentDb.Execute SqlRemoveFromOrders
End FunctionBest regards
-
WSaral
AskWoody LoungerThank you for your reply.I have followed your advice,but i am afraid i didnt follow it properly,since i receive this time Syntax error.
Obviously my line
< " & CnstBefore & "))"is not right.May you help me write it correctly?
best regards
===============================Public Const CnstBefore As Date = #6/1/2003#
Public Function DeleteAllBefore1()Dim SqlRemoveFromOrders
SqlRemoveFromOrders = "DELETE DISTINCTROW orders.orderdate AS Expr1 " & _
" FROM orders WHERE WHERE (((orders.orderdate) < " & CnstBefore & "))"CurrentDb.Execute SqlRemoveFromOrders
End Function -
WSaral
AskWoody LoungerMay i have a small help?
i have copied your proposal and made a function, but obviously
i have missed something, since i receive the message
for IntLoop that variable is not defined.The function is below:Public Function Test()
Dim strDepot As String
For intLoop = 1 To 3
strDepot = Choose(intLoop, DSo, DVa, DBi)
If Dir(strDepot, vbNormal) “” Then
Call FromDepot(strDepot)
UpdateTables
Kill (strDepot)
End If
Next intLoop
End FunctionBest regards
-
WSaral
AskWoody LoungerThank you !!! it is exactly what i wanted. I see i was not very clear but you did guess what i need and it will solve my problem.
Warm regards
-
WSaral
AskWoody Loungeri want to explain further what i have done with the hope that i will be more clear and thus receive the help i need
I have tried to build the code but i received
an error in the line tdf.Fields.Name = “CustomerID” with the message
” method or data member not found.” Can you help me build the right way ? Below is my codeDim wsp As DAO.Workspace
Dim StrPassword As String
StrPassword = “password”
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set wsp = DAO.DBEngine.Workspaces(0)
Dim dbs As DAO.Database
Set dbs = wsp.OpenDatabase(“C:BEstoreBE.mdb”, False, False,“;PWD=” & StrPassword)
Set tdf = dbs.TableDefs(“CallsCustomers”)
Set fld = tdf.Fields(“ContactID”)
tdf.Fields.Name = “CustomerID”
tdf.Fields.Refresh
dbs.Close
Set fld = Nothing
Set tdf = Nothing
Set dbs = Nothing
Set wsp = Nothing -
WSaral
AskWoody Lounger(Edited by charlotte on 03-May-03 06:47. remove unnecessary line breaks)
How not to open a report ?
I am looking for a way to stop the execution of a code for opening a report in case the customer has not chosen an option.However it
seems that my way of doing things is not right.My option box is called Office,and i have put the command Exit Sub in case no option is chosen, but Access seems to neglect my command.Where am i wrong?The command i have is the following :
If Me![Office] = False Then
MsgBox ” Please select a city”
Exit Sub
Else
Dim stDocName As String
Select Case Me![FrameCalls]
Case 1
stDocName = “CallsCustomers1”
Case 2
stDocName = “CallsCustomers2”
End Select
DoCmd.OpenReport stDocName, acPreview
End If -
WSaral
AskWoody Loungeri have made a mistake in my question:
instead of Detail section i have written order section -
WSaral
AskWoody LoungerThank you !!! it works great now !
-
WSaral
AskWoody LoungerThank you for your reply.Both tables are in the same database.The table1 is corrupted,but it is a part of a relationship, and i cannot make the relationship with tables filled with data. I am trying to evade this problem,and i am sending this code
in another town,so the best way will be if i append all the data from the table2 into the blank table2. Can you help me writing the code ?regards
-
WSaral
AskWoody LoungerDear Hans,
Thank you so much for your reply which after i applied it, my code works excellent!!!!
Could you help with one very similar function called ProcessOrder and here again i have the same problem,
when i choose the preview the document, i print it.Thank you so much in adcance fro your wonderful remarks !!!!!!!!
Here is my function as follows:
Public Function ProcessOrder()
‘ the function is placed in the control CmdOrders being the output for the ListOrders
Dim f As Form
Set f = Forms![FOrderInformation]
If IsNull(f!
Dim intPrint As Integer
Dim intAnswer As Integer
intAnswer = MsgBox(” Delete? “, vbQuestion + vbYesNo)
If intAnswer = vbYes Then
Application.Echo False
CancelOrder
Else
Dim intTrst As String
intTrst = MsgBox(” Transform? “, vbQuestion + vbYesNo)
If intTrst = vbYes Then
ftransform
Else
intPrint = MsgBox(” Print? “, vbQuestion + vbYesNo)
If intPrint = vbYes Then
direct ‘ this function prints 4 copies
Else
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
VisibleOrder
End If
End If
End If
End If
End Function -
WSaral
AskWoody LoungerThank you for your reply.Yes, i will use a parameter later on, but my problem is substracting from 2 queries.For say customer Nr 118, i have 2 queries
which are differennt.I want to substract the liters from the 2 queries.I can do it with three queries,but i woulld like to use VBA in order to make things more flexible,use parameters,etc.Can you help me further?If you look at my thrid query,you will see it is based on the previous 2 queries.i want to aoid the use of three queries,if possble.Actually the thrid query only substracts the quantity from the 1 st query and the 2nd query.So,to make my question more clear please forget the customer,and take it to be a constant figure. If i solve the case for this customer,as you have already noted i can solve it for ther other customners too.Best regards
-
WSaral
AskWoody LoungerYour suggestion did update ! Thank you.I feel obliged to expplain why i am doing this.The reason is that one ofmy fields will be obsolete in the future the other is brand new and i want to copy the availabe information
best regards -
WSaral
AskWoody LoungerThe fields stock ,items,branch0 and item0 are fields in the table products.You could see that from my query where i write products.stock, which means this is a field stock from the table products.Also i do not receive any error, but the fields are not updated.Also,as i mentioned ,the query i have shown is working, but i cannot explain myself why the function is not working, which means that the function is not updating.
-
WSaral
AskWoody LoungerThank you so much for your kind and so clever answer. I really think it makes wonders with our programme.I have applied it and it works
excellent.
May i ask you fir a little further help? When i tried to apply your suggestion to a code very similar to this, i somehow could not
manage to get it right becasue i obtain the line of code called “bas” highlighted with red.I am wrong with my commas and brackets.Could you please have a look?
AT first my new code made on the basis of your suggestions, and below the old function that i want to modifyPublic Function MainProductStrings()
Dim city As Long
city = Forms![FOrderInformation]![office] – 1
Dim bas As String
bas = ” SELECT products.Productid, products.grade, products.code,products.size,products.pack, ” & _
” products.branch” & city ,& “, products.items” & city ” & _
” FROM Products – here i receive red highlighted letters from AccessDim strDocName As String
strDocName = “FOrderinformation”
If IsOpen(strDocName) = True Then
bas = bas & ” WHERE(((products.branch” & Forms![FOrderInformation]![office] & “) > 0))ORDER BY products.grade ASC”
End If
MainProductStrings = bas
End FunctionPublic Function OldMainProductStrings()
Dim strOffice As String
Dim strVaM As String
Dim StrBuM As String
Dim strBlM As String
Dim strHaM As String
Dim strPlM As String
Dim strTaM As String
Dim strTaM As String
Dim strRsM As StringStrBuM = ” SELECT products.Productid, products.grade, products.size, products.branch0, products.item0 FROM products WHERE (((products.branch0) > 0))
ORDER BY products.grade;”
strVaM = ” SELECT products.Productid, products.grade, products.size, products.branch1,products.items1 FROM products WHERE (((products.branch1) > 0))ORDER BY products.grade;”
strBlM = ” SELECT products.Productid, products.grade, products.size, products.branch2,products.items2 FROM products WHERE (((products.branch2) > 0))ORDER BY products.grade ;”
strHaM = ” SELECT products.Productid, products.grade, products.size, products.branch3,products.items3 FROM products WHERE (((products.branch3) > 0))ORDER BY products.grade ;”
strPlM = ” SELECT products.Productid, products.grade, products.size, products.branch4,products.items4 FROM products WHERE (((products.branch4) > 0))ORDER BY products.grade ;”
strTaM = ” SELECT products.Productid, products.grade, products.size, products.branch5,products.items5 FROM products WHERE (((products.branch5) > 0))ORDER BY products.grade ;”
strTarM = ” SELECT products.Productid, products.grade, products.size, products.branch6,products.items6 FROM products WHERE (((products.branch6) > 0))ORDER BY products.grade ;”
strRsM = ” SELECT products.Productid, products.grade, products.size, products.branch6,products.items6 FROM products WHERE (((products.branch7) > 0))ORDER BY products.grade ;”
Dim strDocName As String
strDocName = “FOrderinformation”
If IsOpen(strDocName) = True Then
Select Case Forms![FOrderInformation]![office]
Case 1
strOffice = StrBuM
Case 2
strOffice = strVaM
Case 3
strOffice = strBlaM
Case 4
strOffice = strHaM
Case 5
strOffice = strPl
Case 6
strOffice = strTrM
Case 7
strOffice = strTaM
Case 8
strOffice = strRsMEnd Select
MainProductStrings = strOffice
End If
End FunctionP.S. if i am right i will not need to hard code each office separately, and i may add on aditional offices without caring to modify my code.
Therefore i treasure so much the suggestions you have madeVery best 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
-
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
2 hours, 27 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
2 hours, 33 minutes ago -
regarding april update and may update
by
heybengbeng
4 hours, 3 minutes ago -
MS Passkey
by
pmruzicka
7 minutes ago -
Can’t make Opera my default browser
by
bmeacham
11 hours, 43 minutes ago -
*Some settings are managed by your organization
by
rlowe44
1 hour ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
10 hours, 37 minutes ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
1 day, 6 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
1 day, 15 hours ago -
AI slop
by
Susan Bradley
5 hours, 25 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
1 day, 16 hours ago -
Two blank icons
by
CR2
4 hours, 20 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 1 hour ago -
End of 10
by
Alex5723
2 days, 4 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 2 hours ago -
test post
by
gtd12345
2 days, 10 hours ago -
Privacy and the Real ID
by
Susan Bradley
2 days ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
2 hours, 39 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
2 days, 14 hours ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 2 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 5 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
3 days, 6 hours ago -
The story of Windows Longhorn
by
Cybertooth
2 days, 17 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
3 days, 8 hours ago -
Are manuals extinct?
by
Susan Bradley
8 hours, 32 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
3 days, 17 hours ago -
Network Issue
by
Casey H
3 days, 4 hours ago -
Fedora Linux is now an official WSL distro
by
Alex5723
4 days, 5 hours ago -
May 2025 Office non-Security updates
by
PKCano
4 days, 5 hours ago -
Windows 10 filehistory including onedrive folder
by
Steve Bondy
4 days, 7 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.