MS Access 2003: User was able to enter an invalid value; how? - ms-access

I have a strange phenomen I can't explain nor reproduce and I'm hoping you have an idea how it was possible for the user to enter an invalid value.
I have an Access-MDB with a form containing an edit field that should only accept time values without any date-information.
The relevant properties of that edit field are as below:
bound to a Date/Time database value (since access know no time-only datatype)
Format: "Time, 24hrs"
Input Format: "99:99"
(I use the german version of Access, so the property names may be a little different, but you see the pattern)
Now I found out that a user was able to enter a date value into that field. I'm nearly 100% sure that it was an accident and no "clever hack" in the form of directly opening the table and editing the corresponding Date/Time field. Since the entry was made back in 2009 (nobody spotted the error), I have no chance to ask the user how it was done.
I found two wrong entries with the dates "01.06.2000" and "01.07.2000" and I guess the user wanted to enter the times "06:00" and "07:00".
I tried every input I can imagine (like "6.0", "6;0", "6,0", copy&paste) but I was unable to trick access and enter anything except digits and the colon.
Do you have any idea what is going on and how the user was able to enter these dates accidentially?

A Jet/ACE Date/Time value is never stored "without any date information". If you attempt to store only the time component, it will actually be stored with the same time on day zero (Dec 30, 1899).
We can only speculate how the incorrect data was added back in 2009. If you want the database engine to require your Date/Time values to be stored with day zero as the date component, you can add a table-level validation rule. From the table property sheet, try this for Validation Rule:
DateValue([your_date_field])=CDate("1899/12/30")
If you want to allow Null for your_date_field, try this version:
IsNull([your_date_field]) Or DateValue([your_date_field])=CDate("1899/12/30")

Several possibilities:
A developer (you?) did it by accident when looking at the raw table
The client Access software went momentarily crazy and corrupted the entry. This has happen to us (fortunately very rarely) where our Access tables will end up with non-ASCII characters in a string field.
A bug in Access runtime allowed the problem in the past, but has been corrected in a service pack.
Finally, if you put in 90 hours, does it overflow into 4 days and something? That might do it.

Related

Why does this expression work in one spot but not another when using the same data?

I have 2 reports here that are machine schedules (Wrap & Moulder). They were working great, until I tried to add a checkbox to say whether or not the previous step had been marked completed. It worked initially on Wrap Schedule but when I did the exact same thing on Moulder Schedule it is coming out as data type mismatches. In the checkbox I have put the expression:
=IsDate([Previous_Date_Ran])
It works great on Wrap Schedule, but as soon as a Date is entered in the [Previous_Date_Ran] field I am getting data type mismatches. I have narrowed it down to whenever a date is put into that field, which is odd because when it is Null there is no issue. I have made sure already that my other form that supplies this [Previous_Date_Ran] field is inserting =Date() and not =Now() or =Time(). Below will be screenshots of it working on Wrap but erroring on Moulder.
[
Thank you if you have suffered through with me so far, any help would be much appreciated!
For anyone still struggling here is the steps I took to fix this problem:
Firstly, I have the field Date_Ran as a Date/Time, formatted to short date. Another form has an on-dbl-click event where it inserts today's date in the field. Turns out when you use =Date() in VBA is assigns it a default Variant type. For whatever reason I believe this was what caused the error. The second I switched to using =Date$() it inserts today's date as a string and the error has stopped. Good luck!

SSRS Pass Date Parameter in URL

I have been trying to figure this out for a while now and I cannot seems to get it to work. I am trying to pass 2 date parameters to an SSRS report. I am using SSRS 2016. The link that gets you to the report is
http://ServerName/Reports/report/SomeFolder/ReportName I have tried following the unanimously agreed upon approach of simply appending &StartDt=01/01/2020&EndDt=01/31/2020 and other combination and listed below.
http://ServerName/Reports/report/SomeFolder/ReportName&StartDt=01/01/2020&EndDt=01/31/2020
http://ServerName/Reports/report/SomeFolder/ReportName&StartDt=01-01-2020&EndDt=01-31-2020
http://ServerName/Reports/report/SomeFolder/ReportName&rs:Command=Render&StartDt=01/01/2020&EndDt=01/31/2020
http://ServerName/Reports/report/SomeFolder/ReportName&rs:Command=Render&StartDt=01-01-2020&EndDt=01-31-2020
In all cases I get the almost the same error, with the only difference being how I added the dates. The path of the item '/SomeFolder/ReportName&StartDt=01-01-2020' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. (rsInvalidItemPath) I have confirmed the parameters match StartDt and EndDt appear exactly that way in my report, just for SAG I even made the prompts match and they are Non null able Date/Time fields. None of available values or default values. If nothing is selected it has the calendar icon to pick a date and everything runs perfectly.
I actually think I saw something on this back in a .Net explanation but it came out to be the link below. As usual I never mark my answer as correct, but leave it for the next person.
http://ServerName/ReportServer/Pages/ReportViewer.aspx?%2FFolderName%2FReportName&rc:showbackbutton=True&StartDt=01/01/2020&EndDt=01/31/2020

MS-Access Web DB "type mismatch" when setting date as string?

This is specifically for MS-Access Web Databases (requires Sharepoint hosting) which has many limitations compared to their client counterparts, like no VBA, instead you get form macros and data macros to manage data.
I've run into a weird bug on one of my applications. I have a query used to check stock levels against a "minimum stock level" also saved in the table. The query is pretty intense and there are over 4,000 records now to check against. These querys normally take about 75s. So I have made a little label that gets updated every time the form is loaded showing the time and date the query was last run, and the duration in seconds it took. (so users can see how fresh the data is and decide if it needs to be run again)
Now, the weird thing is it works fine in my Access client, but when I sync my changes to the server and try it in a web browser I get a "type mismatch" error. A small table is used to store the start and end times whenever the query is run, that's how I get the timestamp data. These fields are in a "Date/Time" format, obviously. But it seems the problem here is changing the date format to a string format so it can be put in a label on the form. The Access client seems perfectly capable of doing this, while the web client stumbles and falls.
My problem is, how do I change data in a date/time format to a string format in a Web database? I can't figure out how to do this. The tools are so limited. I may have to end up answering my own question here but I'm posting this for others just in case.
To return a value from a data macro as string, you have to format the internal date/time format as a string. In Access an internal date/time value is a double number with the integer part as number of days since 1900, and the “decimal” time part is a fraction of 24 hours. Unfortunately if you simply wrap the date/time in the str$() function we had for 20+ years, then you get something JUST like if you type this into the debug window:
? cdbl(now())
41955.5478587963
The solution is to simply pull out each part. And “nice” is while in few cases a data macro will cast the data type, it does in this case and thus the STR$() command is not required.
The expression you thus can use is this:
Month([d]) & "/" & Day([d]) & " Time = " & Hour([d]) & ":" & Minute([d])
So say to pluck out the VERY LAST start time column from say a invoice table, since we don’t have a dmax(), then we simply sort the table in the order we want and pull out the first row.
Our data macro will thus look like:
Note how in above I simply typed in the SQL and SET the order on the date/time column. I want the MOST recent invoice start date and time. For those new to SQL, then I suggest you build a query in the query builder and specify a query in above lookup feature, since many are not "comfortable" typing in free hand SQL as I did above.
Now, in your browser side (UI) macro, you can use this code:
The above returns a formatted string that you can stuff into a text box, or as per above code change the caption of a label.
Unfortunately with silly problems like this, it becomes a path-of-least resistance thing.
Since my intended result was simply to get "a timedatestamp from a table to show up on a form (so users could see when a query was last run)", this became redesigning my form in Access to be a text field instead of a label. Text fields can be adjusted to accept "Time/Date" formats, so this is exactly what I did, it now pulls the timestamp data directly from the last record of the table and requires no extra formatting to appear in the web browser. I redesigned the text field to appear and function more like a label, and my desired function was achieved.
However, since my question specifically asks, "how do you change a time/date format into a string format in a Web db?", I will leave it here in case someone actually does solve it.

MS-Access (Forms): allow user to enter invalid data in a bound, typed TextBox, with intent of correcting it programmatically. How?

I am in the habit of typing date/times in a YYYYMMDDHHmmss format without separators, e.g. "20110807050000" and I want to rig my "date" TextBoxes in an Access form to allow me to enter dates this way.
The TextBoxes in question are databound to Table fields that are of Date/Time type.
The way I have chosen to approach this is just to parse what I type and if I can get a valid date-time out of it, stick it back in the text box. The parsing etc. is complete and ready to go but I am stuck figuring out how to wire it into the form.
Normally (I think .. access/VBA is a bit rusty ..) I would use "BeforeUpdate" event of a control to handle this kind of thing but the problem here is the Form is triggering its default validation error 2113 "the value you entered isn't valid for this field" before it even gets around to running the Control-level events.
Then when I tried parsing/updating the TextBox in the Form_Error procedure, i get a 2115 error "The macro or function set to the BeforeUpdate or ValidationRule property of this field is preventing [...] saving the data in the field." In the Control.BeforeUpdate scenario, I think you can use the "Cancel" flag to get around this sort of hang-up, but Form.OnError event doesn't have anything like that (at least "Response" doesn't seem to be doing the trick.)
edit-just to be complete: I also occasionally might want to use traditional "MM/DD/YY HH:mm:ss [AM/PM]" (or similar) form, and also that I already have parsing in place for pasting dates off the clipboard in another "common" format (the one used in Windows Explorer's Properties dialog), and would like this capability to remain, and remain extendable.
Kinda stumped. Figured I would ask around a bit before resorting to some really invasive/ugly hack to get this working.
Thanks for reading! Any suggestions/solutions are appreciated!
Solution to-date:
Created an additional unbound TextBox to do my data-entry in.
UnboundTextBox.OnLostFocus I try to parse a valid date out of what has been entered and, if a valid date is the outcome, insert that in the original bound TextBox for the field (now Locked).
Form.OnCurrent I copy whatever is in the bound TextBox to the unbound one, to ease editing of existing data.
Pretty basic, and pretty nasty, but, as it's an app for personal use, it's workable, and I've basically already grown accustomed to seeing the extra TextBox on the screen. (I suppose it could be hidden, but I started with it Visible, for debugging purposes, and just left it that way, so far.)
Instead of BeforeUpdate you can use the KeyDown event and have it respond to Enter, Tab, PgUp, and PgDn. This will execute code when you leave the field or record but before validation (what BeforeUpdate SHOULD do). The only drawback is that the code won't run if you use the mouse to leave the field.
I used this to to convert directions like N, NE, WSW to degrees in an integer field. It isn't perfect but is good enough.

MS Access setting to ignore date conversion error

An Access DB imports a fixed width text file; one column is mostly dates.
When the date is not available, the file's creator actually uses the string "Null"
Access puts the row in the table with that field actually null.
But, when the files started coming with different field widths, I copied the DB, tweaked the starting/width values in the input spec, and imported. NOW, all the rows with null get logging in (table)_import_errors as an error converting text to date.
I have found no setting (not that I changed any) to explain it. One difference is that although both DBs are in Access 2000 format, the original is on a machine that still has Access 2000, while the new one is being handled by Access 2003.
Is that a behavior change in the Access version? Is pre-processing the file the only solution?
Thanks, David. That's what I would have done (except for the Excel part) if it had not fixed itself. I posted that, but apparently someone didn't like the public admission that Access has bugs.
The only thing that changed was that two other columns in the fixed width plain text input was wider. Yet Access "decided" to discard the whole row instead of just the date field for three consecutive attempts. The fourth time, it still reported it as an error but imported the rest of the row.
So, when Access misbehaves for no good reason, try again a time or two, then try explicitly coding the conversion from text.
Two possibilities:
Use a buffer field or buffer table that imports the date field into a text field. Then you can process that into the appropriate values in the final destination field.
Use a SQL import instead of DoCmd.TransferText. What you do in that case is use a connect string in the FROM clause so you can then process the date field in your SELECT:
SELECT Sheet1.FirstField, Replace(Sheet2.DateField, "NULL", Null) As DateField
FROM Sheet1 IN 'C:\Import\Spreadsheet.xls'[Excel 5.0;HDR=YES;IMEX=1;];
Convert that into an INSERT query and you're golden.