Forum Discussion
VBA issue
Does your code compile without errors?
Have you tried an Office Repair?
What Access build no are you currently running? Have you tried updating to see if it is an issue with that specific build?
- cmancasJul 26, 2020Copper Contributor
Thank you for your message Daniel_Pineault!
1. Yes, code is compiling w/o errors; here it is:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'***********************************************
Dim EmbTimeZone, DestTimeZone As Variant
Dim ETZ, DTZ, FlightMins, FlightH, FlightM As IntegerOn Error GoTo err_point
Stop
If Not Me.NewRecord And Me!Embarkment = Me!Embarkment.OldValue And Me!Destination = Me!Destination.OldValue And Me!TakeOffLocDateTime = Me!TakeOffLocDateTime.OldValue And Me!LandingLocDateTime = Me!LandingLocDateTime.OldValue Then GoTo exit_point
EmbTimeZone = DLookup("TimeZone", "CITIES", "x=" & DLookup("City", "AIRPORTS", "Embarkment=" & Me!Embarkment))
ETZ = CInt(EmbTimeZone)
DestTimeZone = DLookup("TimeZone", "CITIES", "x=" & DLookup("City", "AIRPORTS", "Destination=" & Me!Destination))
DTZ = CInt(DestTimeZone)
FlightH = IIf(ETZ * DTZ < 0, Abs(DTZ) + Abs(ETZ), Abs(DTZ - ETZ))
FlightMins = Abs(CInt(DateDiff("n", Me!LandingLocDateTime, Me!TakeOffLocDateTime))) + FlightH * 60
If FlightMins <= 0 Then
Cancel = True
Beep
MsgBox " ... and, instead, it is " & FlightMins & " minutes!", vbCritical, "Wrong data rejected: flight time should be strictly positive..."
Else
FlightH = FlightMins / 60
FlightM = FlightMins Mod 60
Me![FlightTime] = FlightH & ":" & FlightM
End If
exit_point:
Exit Sub
err_point:
Cancel = True
MsgBox Err.Source & " -> " & Err.Description, vbCritical, "Error in method Form_BeforeUpdate of module OPTIONS..."
End Sub2. No I did not repair Office: I do not think it needs, all other applications are working fine. Moreover, very complex Access applications that I developed in years under previous US Access versions are working fine even under this Romanian one as well.
3. Being a subscription, I always have the latest version that is updated automatically immediately after such updates are available. Currently, it is compilation 130001.20384 of the 2006 version.
Moreover, before contacting Microsoft, I tried one of the "solutions" circulating on the net, namely to change the international settings of Windows to Romania (instead of US), but in vain, the VBA code is not running either and Access is issuing the same error message.
Thank you once more for your time and kindness,
Christian
- cmancasJul 26, 2020Copper Contributorp.s. Stop is obviously inserted only for debugging purposes, but it is not reached.
- cmancasJul 26, 2020Copper Contributorp.p.s. I also tried in vain to delete and recreate the form, as well as to compact and repair this tiny db, both under US and Romanian Windows settings.