-
WSJayden
AskWoody LoungerYou need to turn off (unreference) your Active X 2.1
-
WSJayden
AskWoody LoungerCan you post the SQL statement from the query that you are trying to use?
-
WSJayden
AskWoody LoungerFirstly, I believe that there is an advantage in not recording the hyphen. We can use input masks or format properties to control how the number are displayed when they do not have the hypehn, but if they cotnain spaces and hypehns, then we are more limited in what we can do (or at least it becomes more difficult).
So..my suggestion would be to record only the phone numbers themselves, no hyphens and no spaces.
Okay, so how can you remove all the hyphens and spaces from a field in a table? Easy. Use the function that I have supplied below (and look how it is used in the example file attached).
To use the below function, place it in a new module in the database with the data you want to modify. Make sure you take a backup (ie. copy it and call it something different) of the data that you are going to be editing, just in case something goes wrong.
You need to pass three variables to the function, all strings
The first variable is the character that you wish to remove (ie. “-“, or ” “)
The second variable is the name of the table (ie. “tblPerson”)
The third variable is the name of the field that you want to search through (ie. “PhoneNumber”)So calling the function would look something like this:
RemoveCharacter(“-“, “tblPerson”, “PhoneNumber”)
This would remove all hyphens from the PhoneNumber field in the table tblPerson.
Note that I haven’t included any error handling routines in this function, if you spell the table name or field name wrong. Just make sure you spell them right, or a funny error may occur (something like object not found in collection).
Hope that this helps
Public Function RemoveCharacter(strRemovalCharacter As String, strTableName As String, strFieldName As String)
‘===============================================================’
‘ Author: Jayden MacRae ‘
‘ Created: 27/10/2001 ‘
‘ Purpose: To remove any characters from a field in a table ‘
‘===============================================================’
Dim rstPerson As Recordset
Dim intHyphenPos As Integer
Dim strFieldValue As StringSet rstPerson = CurrentDb.OpenRecordset(strTableName, dbOpenTable)
With rstPerson
Do Until .EOF
Do
strFieldValue = .Fields(strFieldName)
intHyphenPos = InStr(1, strFieldValue, strRemovalCharacter)
If intHyphenPos > 0 Then
strFieldValue = Left(strFieldValue, intHyphenPos – 1) & _
Right(strFieldValue, Len(strFieldValue) – intHyphenPos)
End If
If strFieldValue .Fields(strFieldName) Then
.Edit
.Fields(strFieldName) = strFieldValue
.Update
End If
Loop Until intHyphenPos = 0
.MoveNext
Loop
.Close
End WithSet rstPerson = Nothing
End Function -
WSJayden
AskWoody LoungerIt sounds to me that if you are mucking around with different platforms and spreadsheets (linked??) eeek, I would go for a nice ‘cross-platform’ option that could interact with your database and doesn’t need any software installe don the ‘client’ machines apart from a web browser ie. ASP.
Of course, this relies on the fact that you have an intranet (or at least the ability to set one up with IIS) and someone who could write the asps (or the time to do/learn it yourself).
This may be completely out of the question, but it is certainly what came to mind for me. I’ve done a couple of ‘sites’ / web applications now that interact with Access 2K databases just nicely.
jayden
-
WSJayden
AskWoody LoungerHi Arage
Cross-tab queries take data in a query and use the values in one column to create a column for each value. This effectively spins the table around.
As far as I know, you cannot enter values into a Cross-tab query (because of the way it calculates the ‘values’, they are aggregates of individual fields).
The way around this would be to create your table to ‘look’ like the structure you want to enter into and base your form on this table. Then at a later stage, use some make table and append queries to turn the column names in your table into values in a new table (or if you didn’t want to do this you could just leave the table how it was).
Hope that this helps
-
WSJayden
AskWoody LoungerI think that you need to approach this problem from a slightly different angle. Instead of using criteria in your SQL (which probably won’t work the way you have it set up), use a Join between the two tables.
I would probably make the code to look something like this:
Dim strSQL as StringstrSQL = “DELETE IssuedTo.* ” & _
“FROM IssuedTo INNER JOIN ImportTemptbl ” & _
“ON IssuedTo.[Voucher#] = ImportTemptbl.[Voucher#];”DoCmd.RunSQL strSQL
What this code does is it creates the SQL in the variable strSQL that joins the two tables by voucher# and where any fields match in the two tables, it deletes the record from the IssuedTo table.
I haven’t tested this, but give it a try and see what happens (make a back-up of your tables first though just in case).
Incidentally the main problem that you were having in the code above was that you had the RST variable inclosed with the quotes of the SQL string you were trying to run.
If you changed the line to:
DoCmd.RunSQL “Delete * from IssuedTo where [voucher#] = ” & RST
It would use the variable, but you will still find that it probably generates an error, because the variable doesn’t contain a value, but rather contains a reference to a field in a table (but for which record?). This is why I would do it the way that I have presented it above.
One other question? Why do it in code? You could just create a DELETE query and just run that at the appropriate time?
Cheers
Jayden
-
WSJayden
AskWoody LoungerYour main problem to me sounds like you need to modify your ‘join’ properties in your query.
At present, it sounds as though your join is an ‘INNER JOIN’ (solid line without any arrows between each table.
An INNER JOIN will only show records where identical values exist in both tables. This is clearly not the case between the customer table and your hours and mileage and weight tables (because sometimes, customer orders don’t have records in one table).
You need to make the join between the Cusomter/Order table and the Hours table so that the query will return ‘All records in the Customers/Order table and those that match in the Hours table’.
You need to make the joing between the Customer/Order table and the Mileagage/Weight table so that the query will return ‘All records in the Customers/Order table and those that match in the Mileage/Weight table’.
To do this, in your query, right click on the each join, select ‘Join Properties’ and then select the appropriate options.
When you have done this, your query should have arrowed joins, moving out from the Customer/Order table, pointing towards the Hours and the Mileage/Weight table.
I would also note that I would have give Hours it’s own table, Mileage it’s own table and Weight it’s own table (not agregated two together). I would have given Customers their own table and Orders a seperate table.
Access comes with an example database called Northwind. This is an inventory and order database. Have a look at it and it might give you some ideas. You may need to learn more about database normalisation too.
-
WSJayden
AskWoody LoungerYou could use
expression:=Round(Avg([Turnarounddays],NumberOfDecimalsToRoundTo)
Use this and replace NumberOfDecimalsToRoundTo with a number (default =0).
-
WSJayden
AskWoody LoungerI vauguely remember reading something on MSDN that demonstrated a very deliberate method of ‘corrupting’ an Access database file. The details are very fuzzy, and I’ve tried looking through MSDN again, but can’t find the article (as I never can) (incidentally why is it that you only ever run into useful articles when you are looking for something entirely unrelated?).
Anyway, this might jog someone elses memory who has seen the ‘method’ for corrupting Access on MSDN
?
I have a sneaking suspicion that it was in amongst some ‘record locking’ stuff.
Anyway, my 2 cents worth
J
-
WSJayden
AskWoody LoungerAt the risk of sounding cheeky?
How about putting the button to undo the subform on the subform? (I know you said you couldn’t because of design changes, but hey…
, sometimes it’s just easier???)
Jayden
-
WSJayden
AskWoody LoungerHi
Firstly I think the (main)problem lies in the fact that you have the button that you want to click on the main form. This is a problem, because as soon as the subform loses the focus (which it does for you to be able to click on the button) it will perform a ‘save’ of the record, promptly followed by your undo command. It will be undoing any ‘unsaved’ changes, but there are none (as you have just saved the changes to the record by clicking out of the sub form).
Secondly, I would tend to use the undo method of the form (or subform) instead of using the docmd object.
For example to undo changes in a form by clicking a button (not a subform) you would use
Private Sub cmdUndoChanges_Click()
me.undo
End SubIf you wanted to reference a sub form from your main form you would use
Private Sub cmdUndoChanges_Click()
me.subformname.form.undo
End SubOf course, this second one won’t work as you want it because of the ‘save’ that happens when you lose the focus from the sub form.
Hopefully someone else knows a ‘work-around’. At least hopefully I have helped you further clarify the problem.
Cheers
Jayden
-
WSJayden
AskWoody LoungerOctober 26, 2001 at 6:57 am in reply to: Shading alternate detail lines in a report (Access 2K) #548738I’ve just realised as an alternative, you can do it without the module level variable.
In this example, I’ve used the same technique, but instead, just checked to see if the current colour of the detail section is white. If it is white, then the colour is set to grey. If it isn’t white, then it is set to white.
Option Compare Database
Option ExplicitPrivate Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
‘===========================================================’
‘ Author: Jayden MacRae ‘
‘ Created: 26/10/2001 ‘
‘ Purpose: set the background colour appropriately or not. ‘ ‘
‘===========================================================’‘Determine if the current line number is a odd or even
‘ number
If Me.Detail.BackColor = 16777215 Then
Me.Detail.BackColor = 12632256
Else
Me.Detail.BackColor = 16777215
End If
End Sub -
WSJayden
AskWoody LoungerOctober 26, 2001 at 6:50 am in reply to: Shading alternate detail lines in a report (Access 2K) #548737Hi
Yes this can be done!
You can use a little bit of VBA to do this.
I have included a sample access 2K file, with a table and report that shades every second line.
You use two events of the Report:
-the On Open event of the report
-the On Format of the detail section of the reportIn the On Open event of the report, set a module level variable to 0
The detail section of a report is ‘formatted’ once for each line of the report. This means that for every line of the report, we can make a bit of VBA run by using the ‘On Format’ event of the detail section of the report.
In the On Format event of the detail section, you need to:
-increment the Line Number variable by 1
-determine if the Line Number is odd or eventTo determine if the line number is odd or even the mod operator is used. The mod operator returns any remainder of the difference between the division of two numbers. For example, 3 mod 2 = 1 (because 3 / 2 = 1 with 1 remaining). If we divide by 2 and there are no remainders (ie. line number divide by 2 has no remainders) then the line is even, else it must be odd.
We then use a if..then..else..end if statement to change the background colour to grey if the number is odd, or white if the line number is even.
There you have it, a report with alternate grey and white lines!
Hope this helps. Unzip the file and run the Acc 2K database, run the report and you will see the result.
Here is the VBA from the Report Module
Option Compare Database
Option Explicit
‘Declare the line number variable and make it available to all
‘ withing the report
Private lngLineNumber As LongPrivate Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
‘===========================================================’
‘ Author: Jayden MacRae ‘
‘ Created: 26/10/2001 ‘
‘ Purpose: To increment the line number by one each time ‘
‘ and then to determine if the line number is ‘
‘ odd or even and set the background colour ‘
‘ appropriately or not. ‘
‘===========================================================’‘Increment line number by one
lngLineNumber = lngLineNumber + 1‘Determine if the current line number is a odd or even
‘ number
If lngLineNumber Mod 2 > 0 Then
Me.Detail.BackColor = 12632256
Else
Me.Detail.BackColor = 16777215
End If
End SubPrivate Sub Report_Open(Cancel As Integer)
‘Initially Set the Line Number Variable
lngLineNumber = 0
End SubCheers
Jayden
-
WSJayden
AskWoody LoungerWe are running a SQL Server 7, on a Win 2K Server, I have written a query using the query analyser and used ‘save as’ to save the sql to a directory. It seemed to save fine. I am using the query analyser from a dektop running win 2K pro?
Can you be more specific? It doesn’t seem to have affected me.
Cheers
Jayden
-
WSJayden
AskWoody LoungerHi
I’ve attached a zip file, with two databases (identible, except that one is a access97 version).
The contain a mock up of how I would go about this:
There are two report, one which shows ‘correct’ results for all graphs. Another which shows results from a table where the results are over 100% for one day, so the graph is not shown.
Personally, I would concentrate on the reason why your graphs are not adding up to 100% – this may be an indication that there are queries that are not correct or dodgey data somewhere.
Hope these files illustrate it better
Cheers
Jayden
![]() |
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
-
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
14 minutes ago -
Stay connected anywhere
by
Peter Deegan
6 hours, 55 minutes ago -
Copilot, under the table
by
Will Fastie
1 hour, 43 minutes ago -
The Windows experience
by
Will Fastie
3 hours, 42 minutes ago -
A tale of two operating systems
by
Susan Bradley
5 hours, 41 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
9 hours, 2 minutes ago -
Where’s the cache today?
by
Up2you2
1 day ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
17 hours, 8 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
8 hours, 7 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
1 day, 1 hour ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
1 day, 17 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
1 day, 17 hours ago -
regarding april update and may update
by
heybengbeng
1 day, 19 hours ago -
MS Passkey
by
pmruzicka
21 hours, 9 minutes ago -
Can’t make Opera my default browser
by
bmeacham
2 days, 2 hours ago -
*Some settings are managed by your organization
by
rlowe44
1 day, 13 hours ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
2 days, 1 hour ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
2 days, 21 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
3 days, 6 hours ago -
AI slop
by
Susan Bradley
1 day ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
3 days, 7 hours ago -
Two blank icons
by
CR2
15 hours, 56 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
17 hours, 54 minutes ago -
End of 10
by
Alex5723
3 days, 19 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
2 days, 17 hours ago -
test post
by
gtd12345
4 days, 1 hour ago -
Privacy and the Real ID
by
Susan Bradley
3 days, 15 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
1 day, 17 hours ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
4 days, 5 hours ago -
Upgrading from Win 10
by
WSjcgc50
2 days, 17 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.