Code Event Criteria

  • Thread starter Thread starter tighe
  • Start date Start date
T

tighe

All,

how can, with the code below, have the f![Location] = Filename line to only
run if everything else occured?

Function SaveAppItem()
Set f = Screen.ActiveForm

surl = f![Hyperlink]
Filename = "\\Bcp\bcp\cmcc\cmcdb\20080922_CMCDB2\Documents\CE\Appendix\" &
f![UpdateNum] & ".pdf"

'With CreateObject("Wscript.Shell")
'Shell ("explorer.exe Filename")
Sleep (3000)
Dim oIExplorer: Set oIExplorer = CreateObject("InternetExplorer.Application")
oIExplorer.Navigate surl
oIExplorer.Visible = True
Sleep (3000)
Do: Loop Until oIExplorer.ReadyState = READYSTATE_COMPLETE
Sleep (2000)
'AppActivate ("InternetExplorer.Application")
'WshShell.AppActivate ("InternetExplorer.Application")

Sendkeys "+^{s}", True
Sleep (2000)
Sendkeys (Filename), True
Sleep (2000)
Sendkeys "{Enter}", True
Sleep (3000)

oIExplorer.Quit
f![Location] = Filename ' this event as long as everything occured
DoCmd.RunCommand (acCmdSaveRecord)

End Function
 
Hi tighe,
I think you can try inserting a doevents commands before the f![Location] =
Filename line so

....all your function
Sleep (2000)
Sendkeys "{Enter}", True
Sleep (3000)

oIExplorer.Quit
doevents
f![Location] = Filename ' this event as long as everything occured
DoCmd.RunCommand (acCmdSaveRecord)

End Function

HTH Paolo
 
paolo,

thank you. i also decided to check the file that is suppoosed to be created
and have a msg box depending on results.

Paolo said:
Hi tighe,
I think you can try inserting a doevents commands before the f![Location] =
Filename line so

...all your function
Sleep (2000)
Sendkeys "{Enter}", True
Sleep (3000)

oIExplorer.Quit
doevents
f![Location] = Filename ' this event as long as everything occured
DoCmd.RunCommand (acCmdSaveRecord)

End Function

HTH Paolo

tighe said:
All,

how can, with the code below, have the f![Location] = Filename line to only
run if everything else occured?

Function SaveAppItem()
Set f = Screen.ActiveForm

surl = f![Hyperlink]
Filename = "\\Bcp\bcp\cmcc\cmcdb\20080922_CMCDB2\Documents\CE\Appendix\" &
f![UpdateNum] & ".pdf"

'With CreateObject("Wscript.Shell")
'Shell ("explorer.exe Filename")
Sleep (3000)
Dim oIExplorer: Set oIExplorer = CreateObject("InternetExplorer.Application")
oIExplorer.Navigate surl
oIExplorer.Visible = True
Sleep (3000)
Do: Loop Until oIExplorer.ReadyState = READYSTATE_COMPLETE
Sleep (2000)
'AppActivate ("InternetExplorer.Application")
'WshShell.AppActivate ("InternetExplorer.Application")

Sendkeys "+^{s}", True
Sleep (2000)
Sendkeys (Filename), True
Sleep (2000)
Sendkeys "{Enter}", True
Sleep (3000)

oIExplorer.Quit
f![Location] = Filename ' this event as long as everything occured
DoCmd.RunCommand (acCmdSaveRecord)

End Function
 
Back
Top