VBA issue

%3CLINGO-SUB%20id%3D%22lingo-sub-1546048%22%20slang%3D%22en-US%22%3EVBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546048%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20been%20redirected%20here%20by%20the%20Office%20Customer%20Support%2C%20where%20I%20got%20the%20following%20session%20case%20number%20for%20today%3A%201008115744.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%2C%20as%20I%20live%20in%20Romania%2C%20Europe%2C%20my%20Office%20365%20license%20bought%20and%20renewed%20twice%20already%20is%20in%20Romanian%2C%20while%20my%20Windows%2010%20is%20in%20English.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20created%20a%20small%20Access%20db%20with%204%20tables%20and%20their%20forms.%20There%20are%20only%20ASCII%20characters%20in%20both%20the%20tables%20and%20the%20forms.%20In%20one%20of%20them%20I%20wrote%20a%20small%20vba%20method%20for%20the%20Form_BeforeUpdate%20event.%20I%20cannot%20test%20it%20because%20I%20got%20the%20message%20saying%20that%20my%20method%20cannot%20be%20run%20because%20there%20is%20a%20communication%20error%20with%20the%20OLE%20server%20or%20an%20ActiveX%20control.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20to%20attach%20the%20corresponding%20db%20file%2C%20but%20it%20was%20rejected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20your%20help%2C%3C%2FP%3E%3CP%3EChristian%20Mancas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1546048%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1546407%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546407%22%20slang%3D%22en-US%22%3ECan%20you%20post%20your%20code%3F%3CBR%20%2F%3EDoes%20your%20code%20compile%20without%20errors%3F%3CBR%20%2F%3EHave%20you%20tried%20an%20Office%20Repair%3F%3CBR%20%2F%3EWhat%20Access%20build%20no%20are%20you%20currently%20running%3F%20Have%20you%20tried%20updating%20to%20see%20if%20it%20is%20an%20issue%20with%20that%20specific%20build%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1546788%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546788%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20your%20message%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F459380%22%20target%3D%22_blank%22%3E%40Daniel_Pineault%3C%2FA%3E!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20Yes%2C%20code%20is%20compiling%20w%2Fo%20errors%3B%20here%20it%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrivate%20Sub%20Form_BeforeUpdate(Cancel%20As%20Integer)%3CBR%20%2F%3E'***********************************************%3CBR%20%2F%3EDim%20EmbTimeZone%2C%20DestTimeZone%20As%20Variant%3CBR%20%2F%3EDim%20ETZ%2C%20DTZ%2C%20FlightMins%2C%20FlightH%2C%20FlightM%20As%20Integer%3C%2FP%3E%3CP%3EOn%20Error%20GoTo%20err_point%3CBR%20%2F%3EStop%3CBR%20%2F%3EIf%20Not%20Me.NewRecord%20And%20Me!Embarkment%20%3D%20Me!Embarkment.OldValue%20And%20Me!Destination%20%3D%20Me!Destination.OldValue%20And%20Me!TakeOffLocDateTime%20%3D%20Me!TakeOffLocDateTime.OldValue%20And%20Me!LandingLocDateTime%20%3D%20Me!LandingLocDateTime.OldValue%20Then%20GoTo%20exit_point%3CBR%20%2F%3EEmbTimeZone%20%3D%20DLookup(%22TimeZone%22%2C%20%22CITIES%22%2C%20%22x%3D%22%20%26amp%3B%20DLookup(%22City%22%2C%20%22AIRPORTS%22%2C%20%22Embarkment%3D%22%20%26amp%3B%20Me!Embarkment))%3CBR%20%2F%3EETZ%20%3D%20CInt(EmbTimeZone)%3CBR%20%2F%3EDestTimeZone%20%3D%20DLookup(%22TimeZone%22%2C%20%22CITIES%22%2C%20%22x%3D%22%20%26amp%3B%20DLookup(%22City%22%2C%20%22AIRPORTS%22%2C%20%22Destination%3D%22%20%26amp%3B%20Me!Destination))%3CBR%20%2F%3EDTZ%20%3D%20CInt(DestTimeZone)%3CBR%20%2F%3EFlightH%20%3D%20IIf(ETZ%20*%20DTZ%20%26lt%3B%200%2C%20Abs(DTZ)%20%2B%20Abs(ETZ)%2C%20Abs(DTZ%20-%20ETZ))%3CBR%20%2F%3EFlightMins%20%3D%20Abs(CInt(DateDiff(%22n%22%2C%20Me!LandingLocDateTime%2C%20Me!TakeOffLocDateTime)))%20%2B%20FlightH%20*%2060%3CBR%20%2F%3EIf%20FlightMins%20%26lt%3B%3D%200%20Then%3CBR%20%2F%3ECancel%20%3D%20True%3CBR%20%2F%3EBeep%3CBR%20%2F%3EMsgBox%20%22%20...%20and%2C%20instead%2C%20it%20is%20%22%20%26amp%3B%20FlightMins%20%26amp%3B%20%22%20minutes!%22%2C%20vbCritical%2C%20%22Wrong%20data%20rejected%3A%20flight%20time%20should%20be%20strictly%20positive...%22%3CBR%20%2F%3EElse%3CBR%20%2F%3EFlightH%20%3D%20FlightMins%20%2F%2060%3CBR%20%2F%3EFlightM%20%3D%20FlightMins%20Mod%2060%3CBR%20%2F%3EMe!%5BFlightTime%5D%20%3D%20FlightH%20%26amp%3B%20%22%3A%22%20%26amp%3B%20FlightM%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3Eexit_point%3A%3CBR%20%2F%3EExit%20Sub%3CBR%20%2F%3Eerr_point%3A%3CBR%20%2F%3ECancel%20%3D%20True%3CBR%20%2F%3EMsgBox%20Err.Source%20%26amp%3B%20%22%20-%26gt%3B%20%22%20%26amp%3B%20Err.Description%2C%20vbCritical%2C%20%22Error%20in%20method%20Form_BeforeUpdate%20of%20module%20OPTIONS...%22%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2.%20No%20I%20did%20not%20repair%20Office%3A%20I%20do%20not%20think%20it%20needs%2C%20all%20other%20applications%20are%20working%20fine.%20Moreover%2C%20very%20complex%20Access%20applications%20that%20I%20developed%20in%20years%20under%20previous%20US%20Access%20versions%20are%20working%20fine%20even%20under%20this%20Romanian%20one%20as%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E3.%20Being%20a%20subscription%2C%20I%20always%20have%20the%20latest%20version%20that%20is%20updated%20automatically%20immediately%20after%20such%20updates%20are%20available.%20Currently%2C%20it%20is%20compilation%20130001.20384%20of%20the%202006%20version.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMoreover%2C%20before%20contacting%20Microsoft%2C%20I%20tried%20one%20of%20the%20%22solutions%22%20circulating%20on%20the%20net%2C%20namely%20to%20change%20the%20international%20settings%20of%20Windows%20to%20Romania%20(instead%20of%20US)%2C%20but%20in%20vain%2C%20the%20VBA%20code%20is%20not%20running%20either%20and%20Access%20is%20issuing%20the%20same%20error%20message.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20once%20more%20for%20your%20time%20and%20kindness%2C%3C%2FP%3E%3CP%3EChristian%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1546792%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546792%22%20slang%3D%22en-US%22%3Ep.s.%20Stop%20is%20obviously%20inserted%20only%20for%20debugging%20purposes%2C%20but%20it%20is%20not%20reached.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1546795%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1546795%22%20slang%3D%22en-US%22%3Ep.p.s.%20I%20also%20tried%20in%20vain%20to%20delete%20and%20recreate%20the%20form%2C%20as%20well%20as%20to%20compact%20and%20repair%20this%20tiny%20db%2C%20both%20under%20US%20and%20Romanian%20Windows%20settings.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1547150%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1547150%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F739999%22%20target%3D%22_blank%22%3E%40cmancas%3C%2FA%3E%26nbsp%3BProbably%20something%20in%20your%20form%20design%20is%20causing%20this...open%20your%20form%20in%20design%20view%20and%20check%20if%20you%20have%20any%20%22unusual%22%20controls...also%20this%20is%20a%20database%20created%20from%20scratch%20or%20something%20you%20copy-paste%20and%20tweaked%20it...maybe%20some%20leftovers%20are%20causing%20the%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1547263%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1547263%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F401564%22%20target%3D%22_blank%22%3E%40tsgiannis%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit's%20a%20db%20created%20from%20scratch%20by%20my%2C%20with%20the%20Access%20form%20wizard%2C%20in%20datasheet%20form%2C%20over%20the%20following%20table%2C%20without%20making%20then%20any%20other%20modification%20than%20adding%20it%20that%20Form_BeforeUpdate%20method%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECREATE%20TABLE%20OPTIONS%20(%3CBR%20%2F%3Ex%20COUNTER%20PRIMARY%20KEY%2C%3CBR%20%2F%3EFlightNo%20VARCHAR(8)%20NOT%20NULL%20UNIQUE%2C%3CBR%20%2F%3EAirline%20LONG%20NOT%20NULL%2C%3CBR%20%2F%3ECONSTRAINT%20fkAirline%20FOREIGN%20KEY%20(Airline)%20REFERENCES%20AIRLINES%2C%3CBR%20%2F%3EEmbarkment%20LONG%20NOT%20NULL%2C%3CBR%20%2F%3ECONSTRAINT%20fkEmbarkment%20FOREIGN%20KEY%20(Embarkment)%20REFERENCES%20AIRPORTS%2C%3CBR%20%2F%3EDestination%20LONG%20NOT%20NULL%2C%3CBR%20%2F%3ECONSTRAINT%20fKDestination%20FOREIGN%20KEY%20(Destination)%20REFERENCES%20AIRPORTS%2C%3CBR%20%2F%3ETakeOffLocDateTime%20DATETIME%20NOT%20NULL%2C%3CBR%20%2F%3ELandingLocDateTime%20DATETIME%20NOT%20NULL%2C%3CBR%20%2F%3EFlightTime%20VARCHAR(5)%2C%3CBR%20%2F%3ECONSTRAINT%20Koptions%20UNIQUE%20(Airline%2C%20Embarkment%2C%20Destination%2C%20TakeOffLocDateTime%2C%20LandingLocDateTime)%20)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMoreover%2C%20on%20the%20smallest%20table%20in%20this%20db%20(%3C%2FP%3E%3CP%3ECREATE%20TABLE%20AIRLINES%20(%3CBR%20%2F%3Ex%20COUNTER%20PRIMARY%20KEY%2C%3CBR%20%2F%3EAirline%20VARCHAR(8)%20NOT%20NULL%20UNIQUE%20)%3C%2FP%3E%3CP%3E)%20I've%20created%20a%20similar%20form%2C%20attached%20to%20its%20class%20this%20super%20simple%20VBA%20method%3A%3C%2FP%3E%3CP%3EPrivate%20Sub%20Form_Open(Cancel%20As%20Integer)%3CBR%20%2F%3EMsgBox%20%22Hello%20world!%22%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3Eand%20the%20result%20is%20the%20same%3A%20I%20got%20same%20error%20on%20impossible%20communication%20with%20the%20OLE%20server%20or%20an%20ActiveX%20control.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20quite%20sure%20that%20this%20not%20a%20programming%20issue%2C%20but%20a%20Romanian%20version%20of%20Access%202016.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20immensely%20regret%20that%2C%20here%2C%20we%20are%20offered%20only%20this%20Romanian%20version%20instead%20of%20the%20US%20one...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%20and%20thanks%20once%20more%2C%3C%2FP%3E%3CP%3EChristian%20Mancas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1547264%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1547264%22%20slang%3D%22en-US%22%3Ep.s.%20please%20excuse%20my%20typo%20errors%20-%20this%20is%20an%20example%20for%20my%20next%20book%20scheduled%20to%20be%20published%20this%20fall%20in%20the%20US%20and%20I'm%20in%20a%20hurry%3A%20of%20course%20that%20the%20db%20was%20created%20by%20me%2C%20not%20by%20my%20%3A)%3C%2Fimg%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1547274%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1547274%22%20slang%3D%22en-US%22%3Ep.p.s.%20there%20is%20also%20a%20missing%20right%20parenthesis%20in%20the%20definition%20of%20the%20kOptions%20key%20%3A)%3C%2Fimg%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi there!

 

I've been redirected here by the Office Customer Support, where I got the following session case number for today: 1008115744.

 

Unfortunately, as I live in Romania, Europe, my Office 365 license bought and renewed twice already is in Romanian, while my Windows 10 is in English.

 

I just created a small Access db with 4 tables and their forms. There are only ASCII characters in both the tables and the forms. In one of them I wrote a small vba method for the Form_BeforeUpdate event. I cannot test it because I got the message saying that my method cannot be run because there is a communication error with the OLE server or an ActiveX control.

 

I tried to attach the corresponding db file, but it was rejected.

 

Thank you in advance for your help,

Christian Mancas

8 Replies
Can you post your code?
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?

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 Integer

On 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 Sub

 

2. 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  

 

p.s. Stop is obviously inserted only for debugging purposes, but it is not reached.
p.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.

@cmancas Probably something in your form design is causing this...open your form in design view and check if you have any "unusual" controls...also this is a database created from scratch or something you copy-paste and tweaked it...maybe some leftovers are causing the issue.

@tsgiannis 

it's a db created from scratch by my, with the Access form wizard, in datasheet form, over the following table, without making then any other modification than adding it that Form_BeforeUpdate method:

 

CREATE TABLE OPTIONS (
x COUNTER PRIMARY KEY,
FlightNo VARCHAR(8) NOT NULL UNIQUE,
Airline LONG NOT NULL,
CONSTRAINT fkAirline FOREIGN KEY (Airline) REFERENCES AIRLINES,
Embarkment LONG NOT NULL,
CONSTRAINT fkEmbarkment FOREIGN KEY (Embarkment) REFERENCES AIRPORTS,
Destination LONG NOT NULL,
CONSTRAINT fKDestination FOREIGN KEY (Destination) REFERENCES AIRPORTS,
TakeOffLocDateTime DATETIME NOT NULL,
LandingLocDateTime DATETIME NOT NULL,
FlightTime VARCHAR(5),
CONSTRAINT Koptions UNIQUE (Airline, Embarkment, Destination, TakeOffLocDateTime, LandingLocDateTime) )

 

Moreover, on the smallest table in this db (

CREATE TABLE AIRLINES (
x COUNTER PRIMARY KEY,
Airline VARCHAR(8) NOT NULL UNIQUE )

) I've created a similar form, attached to its class this super simple VBA method:

Private Sub Form_Open(Cancel As Integer)
MsgBox "Hello world!"
End Sub

and the result is the same: I got same error on impossible communication with the OLE server or an ActiveX control.

 

I'm quite sure that this not a programming issue, but a Romanian version of Access 2016.

 

I immensely regret that, here, we are offered only this Romanian version instead of the US one...

 

Best regards and thanks once more,

Christian Mancas

p.s. please excuse my typo errors - this is an example for my next book scheduled to be published this fall in the US and I'm in a hurry: of course that the db was created by me, not by my :)
p.p.s. there is also a missing right parenthesis in the definition of the kOptions key :)