Link to home
Start Free TrialLog in
Avatar of yballan
yballanFlag for United States of America

asked on

Run-time error '3188'

Dear Experts,

I am having a difficulty debugging my code, which first seemed to be a timing issue.
I have a database with a field that contains large memo field which is to be viewed by previewWin, which is an OLE Class (Microsoft Web Browser)

In order to do that, first I write this memo field out to a local html file by the following code.

Private Sub Command88_Click()
memoBlob = Me.Description
Open "c:\ECEditor\prvWin.html" For Output As #1
Print #1, memoBlob
Close #1
PauseTime = 0
start = Timer
Do While Timer < start + PauseTime
   DoEvents
Loop
DoCmd.OpenForm "previewWin", acNormal
End Sub

Then previewed with this:

Private Sub WebBrowser3_Enter()
     Me.WebBrowser3.Navigate ("c:\ECEditor\prvWin.html")
End Sub

The preview works fine, but the error occurs when I try to go back to one of my forms in following code:

Private Sub Form_Activate()
Set dbsDatabase = CurrentDb
CurrID = DLookup("ShouhinID", "RecordOffset", "[ID] = 1")
PauseMe (0.4)   ' otherwise we get record_locked_error
StrCond = "ShouhinID = " & CurrID
PauseMe (0.4)
Forms![NewProduct_desc].FilterOn = True
PauseMe (0.4)
Forms![NewProduct_desc].Filter = StrCond           <--- here is where it stops.
End Sub

The error is "Run-time error '3188'
could not update; currently locked by another session on this machine"

As you can see, I tried to put some pauses in case there was a timing issue, and played around with the length of the pause, but it does not seem to make any difference.
Now I am starting to suspect that my writing to html file has something to do with it because the error only happens when I update this memo field, preview, then try to go back to my form again.
I am totally stumped, please advise.
Avatar of clarkscott
clarkscott
Flag of United States of America image

Try using FREEFILE instead of static #1.  Freefile picks the next available file number.

Dim f as long
f = freefile
Open "c:\ECEditor\prvWin.html" For Output As #f
Print #f, your stuff

Close f

Scott C
Avatar of yballan

ASKER

Dear Scott C,

Thank you for your prompt reply, I tried it, but still the same error.  :(
ASKER CERTIFIED SOLUTION
Avatar of clarkscott
clarkscott
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yballan

ASKER

Dear Scott C.

After reading your comment, I did delete Form Activate event, and instead, used Form Current event, and the error went away.  Thank you so much!!!!!!
I'm glad it worked out for you.
-s