-
WSStewart
AskWoody LoungerFantastic, I’m glad to have helped.
The fact that the code fixed the import file meant that there was a problem with record terminators.
Stewart
-
WSStewart
AskWoody Loungertry using the NZ function rather than the iif statement that you are using
ie
Private Sub Report_Activate()
Dim var24Hrs As Integer
Dim var48Hrs As Integer
Dim var72Hrs As Integer
Dim var1Wk As Integer
Dim varMoreThan1Wk As Integervar24Hrs = nz([24 Hrs]), 0)
var48Hrs = nz([48 Hrs]), 0)
var72Hrs = nz([72 Hrs]), 0)
var1Wk = nz([1 Week]), 0)
varMoreThan1Wk = nz([More Than 1 Week]), 0)[24 Hrs] = nz([EIR Total],0) – var48Hrs – var72Hrs – var1Wk – varMoreThan1Wk
End Sub
what datatypes are the fields, the iif statement you posted and the nz function just check for null. Are the fields numeric or is it possible that you are passing a string value for a calculation.
-
WSStewart
AskWoody LoungerTrudi,
There are no stupid questions. CR = Carriage Return. LF = Line Feed. Access seems to need this combination to determine the end of a record for text import.
To check what the text file is using for record terminators I’ve attached a small db. Open your text file and copy a few lines. Paste them into the first record in the table and run the function read in the module. the instances of lf or cr are shown in the debug window 10 = lf 13 = cr.
The sample data will display 13 13 10 for each record and access will not be able to import this file as there is not a clean record terminator that it can understand.
The function for fixing a text file is as follows.
Cheers
StewartFunction text_clean(InDirectory As String, Infile As String, Optional OutDirectory As String = “”, Optional Outfile As String = “”)
‘#####################################################################################
‘# Function takes input file and reads it, converting Line Feeds to Carriage Returns #
‘# This in effect cleans up files from the VAX and makes them easier to import into #
‘# Microsoft Access 97. #
‘# #
‘# If the Output File Name is not specified then the original file is overwritten, #
‘# Else the new file created is specified by OutFile #
‘# #
‘# #
‘# #
‘# #
‘# This program assumes 8.3 format, it will work with others, if the file name has #
‘# two “.” in the name, then there may be some unexpected results #
‘#####################################################################################On Error GoTo Error_Text_Clean
text_clean = “”Dim x As Integer
Dim y As Integer
Dim Message As String
Dim a_char As String
Dim a_line As String
Dim overwrite As Boolean
Dim Path_InFile As String
Dim Path_OutFile As String
Dim Path_FileDelete As String
Dim filelength As Long
Dim currentrecord As Long
Dim meterReturn As Variantoverwrite = False
x = FreeFile
If Dir(InDirectory & Infile) = “” Then
MsgBox “Input File ” & Infile & ” ,In Directory: [” & InDirectory & “] Does Not Exist, Please check import file has been created and try again”, vbCritical
Exit Function
End IfPath_InFile = InDirectory & Infile
Open Path_InFile For Input As xy = FreeFile
If Len(Outfile) + Len(OutDirectory) = 0 Then
overwrite = True
End IfIf overwrite = True Then
Path_OutFile = InDirectory & “temp.txt”
Else
Path_OutFile = OutDirectory & Outfile
End IfOpen Path_OutFile For Output As y
currentrecord = 0
filelength = LOF(x)meterReturn = SysCmd(acSysCmdInitMeter, “Checking Import Text File Format”, filelength)
Do While Not EOF(x)
Do
a_char = Input(1, #x)
currentrecord = currentrecord + 1
meterReturn = SysCmd(acSysCmdUpdateMeter, currentrecord)If InStr(vbCrLf, a_char) = 0 Then
a_line = a_line & a_char
End IfLoop While a_char vbLf
Print #y, a_line
a_line = “”
LoopClose x
Close yIf overwrite = True Then
Path_FileDelete = InDirectory & Left$(Infile, InStr(Infile, “.”)) & “old”
If Dir(Path_FileDelete) > “” Then ‘(delete .old file if it exists)
Kill Path_FileDelete
End If
Name Path_InFile As InDirectory & Left$(Infile, InStr(Infile, “.”)) & “old” ‘rename existing input file to .old
Name Path_OutFile As Path_InFile ‘rename output file to input file name
End Iftext_clean = Path_OutFile
meterReturn = SysCmd(acSysCmdClearStatus)
Exit FunctionError_Text_Clean:
Close x
Close yMessage = “An Error Occured while processing ” & Infile & vbCr & “Import File May Be Corrupted”
MsgBox Message, vbCritical
MsgBox “Please Write Down this Error Number and Description and seek assistance” & vbCr & “Error Number ” & Err.Number & vbCr & “Error Description ” & Err.Description, vbExclamation
text_clean = “”
meterReturn = SysCmd(acSysCmdClearStatus)
End Function -
WSStewart
AskWoody LoungerHi Trudi,
The user downloads the file, how? if this is via ftp you may wish to check the transfer protocol that the user selects. I’ve got a few users who occasionally transfer their text files as binary rather than as ascii. this generally creates a problem where the record terminators are not complete so Access return a message RECORD LENGTH TO LONG.
Check the record terminators to ensure that there is a CR/LF pair, if one is missing access gets confused, versions after Access 2 anyway.
I’ve got some code that will process your text file and save a new version with a clean record terminator if you want it.
I have processed the text file pre import in some applications but it does add to the processing time.
If the problem only exist for one user, the problem relates to either what they are doing or their machine. I’d try to establish the cause before coming up with esoteric workarounds.
Stewart
-
WSStewart
AskWoody LoungerYou said “if two people have the db open to add a number, both instances will see the most recent number, add 1 to it and give the same number. if one finishes and clicks ok to enter the job number before the other finishes (at least by a few seconds) when the second accepts the data, it will say the job number is already in use.”
This seems to be the problem. The job number is generated for the data entry and not immediately posted to allow the second user to obtain the next number in the sequence. You can use the before insert event to populate the job num and post the record.
A better solution is or leave the Jobnum blank until post and then get the next number in the sequence. Use the before update event to check if the job num is populated and if not populated grab the next number in the sequence.
This will allow you to maintain a sequence without any gaps and without having two users recording the same job number. As one of the other posts said your sequence of job numbers probably should be in a seperate table, just to make life easier for you.
-
WSStewart
AskWoody LoungerIs rst!ColumnCount equal to 3?
-
WSStewart
AskWoody LoungerIt’s a shame I didn’t read you rpost sooner or I’d have saved you a couple of days stumbling.
Glad to of been of some assistance, even if it was to late.
Cheers
Stewart -
WSStewart
AskWoody Loungergo to the command prompt,
type set
press enter.Can you see the required username there?
if so you can use the
environ(“username”) statement where username is the environment variable I’m interested in for this example. -
WSStewart
AskWoody LoungerYou’ll probably need to make the subforms unbound and post the data entry to the tables via code. It’s going to take a bit more effort but you should be able to get the effect and functionalit that you need.
Stewart
-
WSStewart
AskWoody LoungerOctober 10, 2001 at 2:41 am in reply to: Combining Fileds from Different tables (Access 97) #1789009Paul,
Ideally the datasource for the report & or form would be the query that you created that contains the concatenated expression. Alternately if this is not practical consider modifying the datasource that you are using to include the concatenated expression so it is displayed in conjunction with each record.
Using the on current event could populate an unbound field fairly readily but that assumes that either the required fields are present in the form or the expression is build in code from the related tables.
Including the expression in the query the form is based on is probably the simplest solution.
Stewart
-
WSStewart
AskWoody LoungerOctober 3, 2001 at 4:31 am in reply to: how to avoid open report action cancelled message (97) #545108You can also trap the error that occurs. This allows you to get a meaningfull error when something unexpected happens.
eg surround your code in a procedure with the following.
at start.
On Error goto Error_trap{code in here)
Exit_Procedure:
Exit Sub
Error_Trap:
Select case err
Case 2501’Report open canceled.
‘do nothing, we accept this error.
Case Else
msgbox Error,vbInformation,Err & “{procedure Name}”
end select
resume Exit_Procedure ‘Quit after error.
This allows you to receive an error description in the msgbox and the error number for trapping if necessary and the procedure where the error occured as the title for the msgbox.Never blindly disable error trapping, as the ability to trap errors and deal with thenm is the primary advantage of using vba over macros.
-
WSStewart
AskWoody Loungeruse UNC paths to prevent the problems with drive mappings.
-
WSStewart
AskWoody LoungerI find that at the start of a procedure if you set the timer interval =0 and then set it back to whatever it was on procedure exit that it doesn’t interfere with my general processing. I do this a lot as I use the timer to check for a log out call in pretty much all my applications.
-
WSStewart
AskWoody Loungerin the line
If Me(“Filter” & intCounter) < "" Then
what is "<". I don't suppose that you can save the attachment as a 97 db so I can look at it?
-
WSStewart
AskWoody Loungerok, this should fix it.
Private Sub Set_Filter_Click() Dim strSQL As String, intCounter As Integer, a Dim frm As Form, ctl As Control Dim varItm As Variant Set frm = Forms!frmFilter Set ctl = frm!Filter1 For Each varItm In ctl.ItemsSelected a = ctl.ItemData(varItm) & "," & a Next varItm For intCounter = 1 To 5 If Me("Filter" & intCounter) "" Then strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " If intCounter = 1 Then strSQL = strSQL & " IN(" & Chr(34) & a & Chr(34) & ") And " Else strSQL = strSQL & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) _ & " And " End If End If Next If strSQL "" Then ' Strip Last " And ". strSQL = Left(strSQL, (Len(strSQL) - 5)) ' Set the Filter property. Reports![rptCustomers].Filter = strSQL Reports![rptCustomers].FilterOn = True End If End Sub
I’m not the same Stewart Tanner, although it was interesting. I’m in Victoria and am a bit to old to be a Uni student.
![]() |
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
-
End of support for Windows 10
by
Old enough to know better
4 minutes ago -
What goes on inside an LLM
by
Michael Covington
18 minutes ago -
The risk of remote access
by
Susan Bradley
8 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
2 hours, 19 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
5 hours, 27 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
5 hours, 29 minutes ago -
EaseUS Partition Master free 19.6
by
Alex5723
6 hours, 27 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
18 hours, 45 minutes ago -
The EU launched DNS4EU
by
Alex5723
1 day, 7 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
21 hours, 48 minutes ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
1 day, 12 hours ago -
Set default size for pasted photo to word
by
Cyn
1 day, 18 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
1 day, 7 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
2 days, 17 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
10 hours, 40 minutes ago -
Small desktops
by
Susan Bradley
9 hours, 46 minutes ago -
Totally disable Bitlocker
by
CWBillow
1 day, 11 hours ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
2 days, 15 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
3 days, 21 hours ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
1 day, 16 hours ago -
Mystical Desktop
by
CWBillow
4 days, 1 hour ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
3 days, 6 hours ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
17 hours, 45 minutes ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
4 days, 16 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
4 days, 19 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
4 days, 17 hours ago -
What is wrong with simple approach?
by
WSSpoke36
2 days, 15 hours ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
5 days, 4 hours ago -
Location, location, location
by
Susan Bradley
3 days, 19 hours ago -
Cannot get a task to run a restore point
by
CWBillow
5 days, 6 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.