error message 424

mana

Registered User.
Local time
Today, 03:32
Joined
Nov 4, 2014
Messages
265
Hello

i have the following code but i have the error message run time error 424
can you help me please?
thank you


Code:
Private Sub Form_Open(Cancel As Integer)
Dim Ret
Ret = IsOpen.Workbooks("G:\Rasteh Mona\Prioritylist.xlsx")
If Ret = True Then
MsgBox "The excel file is already in use by another user.please close the excel file and try agin"
End If
DoCmd.SetWarnings False
DoCmd.RunSQL ("drop table [tbl];")
DoCmd.SetWarnings False
DoCmd.RunMacro "Macro1"
DoCmd.RunSQL ("delete * from [asli];")
DoCmd.RunSQL ("insert into [asli] select * from [tbl];")
MsgBox "Updates have been done successfully."
End Sub
 
What is the text of the error? What line? You realize your code continues even if the file is open? You need to add

Exit Sub

After the message box.
 
i have error message runtime error 424. object required.
I wrote this code in open event of the form and when i open the form immediately i have this error mnessage. immediately i have this error message even the file is open.
 
I'm not familiar with IsOpen.Workbooks; is that a custom function or class?
 
Not sure what your macro does, but if it dosen't create table [tbl] and you've dropped table [tbl]

There's no table [tbl] object for this line:
DoCmd.RunSQL ("insert into [asli] select * from [tbl];")
 
Last edited:
hello

i created tbl before and here i just want to know if the excel file is open not to use it. cna you help me please?

does someone knows about this?
 
Hello

Code:
...
Ret = IsOpen.Workbooks("G:\Rasteh Mona\Prioritylist.xlsx")
...End Sub

IsOpen - Seems this is expected to be an Object. If it is, it is not set with a value.

What it it?
 

Users who are viewing this thread

Back
Top Bottom