Stang70Fastback
Registered User.
- Local time
- Today, 01:41
- Joined
- Dec 24, 2012
- Messages
- 132
Hi guys. Did what everyone here suggested I do and converted my back end to SQL Server. I'm still learning SQL, so I'm tracking down all the things that broke during the migration and am trying to fix them one at a time. Here is a bit of code that worked fine when the back end was in Access, but acts funny now that it's SQL-based.
This runs in the "On Current" event of the form:
In order, basically it checks that you (have the right username AND the current date/time hasn't exceeded the "timeout" value for that form stored in another table), OR it's a new record, OR you're an admin. If any of those are true, you can edit the form, otherwise you can only view it.
Now that I have the back end in SQL, the code seems to work properly UNLESS I scroll to a new record. Then I get: "Run-time error '2427': You entered an expression that has no value."
Does anyone have any idea what is different in SQL? I know offhand SQL seems to handle dates a bit differently, so maybe that's my issue?
EDIT: My issue lies in the "greater than" statement. Me.SubmitTimestampTXT.Value will be a null value on a new record. Now that I see this, it's obvious, but this code worked before I converted to SQL, which makes me wonder why it is being handled differently. Hmm... how to solve this conundrum.
This runs in the "On Current" event of the form:
Code:
If (Me.SubmitNameTXT = fOSUserName() And Me.SubmitTimestampTXT.Value > (Now - TimeSerial(0, _
DLookup("Delay", "RecordLocking", "Form = 'CDL Exam'"), 0))) Or Me.NewRecord = True Or _
DCount("[Username]", "USER", "[Username] = '" & fOSUserName & "' AND [Authority] = 'Admin'") = 1 Then
In order, basically it checks that you (have the right username AND the current date/time hasn't exceeded the "timeout" value for that form stored in another table), OR it's a new record, OR you're an admin. If any of those are true, you can edit the form, otherwise you can only view it.
Now that I have the back end in SQL, the code seems to work properly UNLESS I scroll to a new record. Then I get: "Run-time error '2427': You entered an expression that has no value."
Does anyone have any idea what is different in SQL? I know offhand SQL seems to handle dates a bit differently, so maybe that's my issue?
EDIT: My issue lies in the "greater than" statement. Me.SubmitTimestampTXT.Value will be a null value on a new record. Now that I see this, it's obvious, but this code worked before I converted to SQL, which makes me wonder why it is being handled differently. Hmm... how to solve this conundrum.
Last edited: