visual basic errors

G

Guest

Hello there,

It is me again. below you will find the line where the debug function send
me. According to the message Run - time error 2364 the database can't open
the table in Datasheet view and it goes to open table " Schedule
PartNoShort". I have checked the table vs spelling but so far I have not been
able to go through..

Could someone give an idea what to do?


Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False
'Open the Table
DoCmd.OpenTable "Schedule PartNoShort", acViewNormal, acEdit
'Delete all records
SendKeys "(^a)", True
SendKeys "{Del}", True
'Close Table
DoCmd.Close acTable, "Schedule PartNoShort"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"


thanks

gustavo
 
D

Duane Hookom

Why open the table?

Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False
'Open the Table
'Delete all records
DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"
DoCmd.SetWarnings True
 
J

John Vinson

Hello there,

It is me again. below you will find the line where the debug function send
me. According to the message Run - time error 2364 the database can't open
the table in Datasheet view and it goes to open table " Schedule
PartNoShort". I have checked the table vs spelling but so far I have not been
able to go through..

Could someone give an idea what to do?


Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False

That's the first problem. If there are warning messages about some
problem you are telling Access "Don't tell me, I don't want to know".
'Open the Table
DoCmd.OpenTable "Schedule PartNoShort", acViewNormal, acEdit

As a rule you should not open tables in view mode AT ALL. They're not
the right tool.
'Delete all records
SendKeys "(^a)", True
SendKeys "{Del}", True
'Close Table

To delete all records in a table, I'd really suggest using a Delete
Query:

DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
DoCmd.Close acTable, "Schedule PartNoShort"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"


John W. Vinson[MVP]
 
G

Guest

Rather than:
DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
I would suggest:
CurrentDb.Execute("DELETE * FROM [Schedule PartNoShort];"), dbFailOnError

It is much faster.

John Vinson said:
Hello there,

It is me again. below you will find the line where the debug function send
me. According to the message Run - time error 2364 the database can't open
the table in Datasheet view and it goes to open table " Schedule
PartNoShort". I have checked the table vs spelling but so far I have not been
able to go through..

Could someone give an idea what to do?


Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False

That's the first problem. If there are warning messages about some
problem you are telling Access "Don't tell me, I don't want to know".
'Open the Table
DoCmd.OpenTable "Schedule PartNoShort", acViewNormal, acEdit

As a rule you should not open tables in view mode AT ALL. They're not
the right tool.
'Delete all records
SendKeys "(^a)", True
SendKeys "{Del}", True
'Close Table

To delete all records in a table, I'd really suggest using a Delete
Query:

DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
DoCmd.Close acTable, "Schedule PartNoShort"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"


John W. Vinson[MVP]
 
J

John Vinson

Rather than:
DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
I would suggest:
CurrentDb.Execute("DELETE * FROM [Schedule PartNoShort];"), dbFailOnError

It is much faster.

yep... and lets you trap errors too. Thanks Klatuu, I was feeling lazy
last night and didn't remember the syntax!

John W. Vinson[MVP]
 
G

Guest

Hello Duane,

Thank you for the answer it help me to go through.

thanks,

gustavo

Duane Hookom said:
Why open the table?

Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False
'Open the Table
'Delete all records
DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"
DoCmd.SetWarnings True

--
Duane Hookom
MS Access MVP
--

Gustavo said:
Hello there,

It is me again. below you will find the line where the debug function send
me. According to the message Run - time error 2364 the database can't open
the table in Datasheet view and it goes to open table " Schedule
PartNoShort". I have checked the table vs spelling but so far I have not
been
able to go through..

Could someone give an idea what to do?


Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False
'Open the Table
DoCmd.OpenTable "Schedule PartNoShort", acViewNormal, acEdit
'Delete all records
SendKeys "(^a)", True
SendKeys "{Del}", True
'Close Table
DoCmd.Close acTable, "Schedule PartNoShort"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"


thanks

gustavo
 
G

Guest

Hi John,

Thanks for the answer it will help me to go through.

Gustavo

John Vinson said:
Hello there,

It is me again. below you will find the line where the debug function send
me. According to the message Run - time error 2364 the database can't open
the table in Datasheet view and it goes to open table " Schedule
PartNoShort". I have checked the table vs spelling but so far I have not been
able to go through..

Could someone give an idea what to do?


Private Sub Form_Open(Cancel As Integer)
'********* Related to the underlying table
'Turn off warnings
DoCmd.SetWarnings False

That's the first problem. If there are warning messages about some
problem you are telling Access "Don't tell me, I don't want to know".
'Open the Table
DoCmd.OpenTable "Schedule PartNoShort", acViewNormal, acEdit

As a rule you should not open tables in view mode AT ALL. They're not
the right tool.
'Delete all records
SendKeys "(^a)", True
SendKeys "{Del}", True
'Close Table

To delete all records in a table, I'd really suggest using a Delete
Query:

DoCmd.RunSQL "DELETE * FROM [Schedule PartNoShort]"
DoCmd.Close acTable, "Schedule PartNoShort"
'Append the new part numbers from JIT
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From JIT Append Query"
'Append the new part numbers from Existing schedule
DoCmd.OpenQuery "Schedule Input Form IV PartNoShort From Schedule Append
Query"


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top