Hi--
I just finished coding an Access sub. Every time I run it, it will go through the first iteration of the "For a = firstsim To nosim" loop and save all of the data correctly. But on the second iteration, it inexplicably stops and returns a 440 runtime error "Automation Error." Help just talks about there being an error in an "automation object." Does anyone have any clue as to what this might mean? If anyone has some spare time, would you mind looking taking a look at the code that follows and maybe give me some suggestions as to an error I'm missing?
Thank you so much!
Ben
----
Private Sub Command21_Click()
Dim Email
Email = InputBox("Please enter your e-mail address for 3DPSSM access.", "Enter e-mail address"
Set dbs = CurrentDb
Set rstprot = dbs.OpenRecordset("proteins", 2)
rstprot.MoveFirst
rstprot.MoveLast
MsgBox (rstprot.RecordCount)
Dim myvar, myvar2
myvar = "h234343*"
myvar2 = Split(myvar, "*", 2)
MsgBox (myvar2(0))
'Specify Min (firstprot) and Max (noprot) record numbers
Dim noprot
noprot = rstprot.RecordCount
Dim firstprot
rstprot.MoveFirst
firstprot = (rstprot.AbsolutePosition + 1)
'Array to store Prots to be sent through 3DPSSM
ReDim CleanedProts(noprot)
CleanedProts(0) = ""
'Loop to strip out stop codons
With rstprot
Dim protst, CleanProt, DirtyProtArray, DirtyProtArray2
Dim CurrProt
For x = firstprot To noprot
protst = !Sequence
DirtyProtArray = Split(protst, ".", 2)
CleanProt = DirtyProtArray(0)
DirtyProtArray2 = Split(CleanProt, "*", 2)
CleanProt = DirtyProtArray2(0)
CurrProt = (rstprot.AbsolutePosition + 1)
MsgBox (CurrProt)
CleanedProts(CurrProt) = CleanProt
.MoveNext
Next x
End With
MsgBox ("Before"
Sleep 3000
MsgBox ("3sec"
'Defines Array to store the URLs of the 3DPSSM jobs
ReDim JobURLs(noprot)
With rstprot
'Submit Loop
.MoveFirst
MsgBox ("submit for loop"
For y = firstprot To noprot
'Defines String to Submit
CurrProt = (.AbsolutePosition + 1)
submitstr = CleanedProts(CurrProt)
MsgBox (!ProteinID)
Dim IE
Dim page As String
Set IE = CreateObject("InternetExplorer.Application"
'Submit as URL
Dim JobURL(6), finalJobURL
JobURL(0) = " JobURL(1) = Email
JobURL(2) = "&seq-desc="
JobURL(3) = !ProteinID
JobURL(4) = "&seq_format=single&global_local=yes&seg=yes&DataFormat=yes&three_iter=no&sequence="
JobURL(5) = submitstr
finalJobURL = Join(JobURL)
IE.navigate finalJobURL
Do While IE.Busy
Loop
Do While IE.ReadyState <> 4
Loop
'Takes return data
page = IE.Document.all.tags("html"
.Item(0).outerhtml
Dim jstart, jend, jURL
jstart = InStr(1, page, "<br><a href=" + Chr(34))
jend = InStr(lstart + 1, page, Chr(34) + " target"
MsgBox (page)
If jstart <> 0 And jend <> 0 Then
jURL = (Mid(page, jstart + 13, (jend - 13) - (jstart + 13)) & ".summaryhits.html"
JobURLs(CurrProt) = jURL
MsgBox (jURL)
End If
.MoveNext
Next y
End With
MsgBox ("Your computer will now wait for 3DPSSM to process the data. While the computer is waiting, Access may appear to be frozen. Disregard these warnings"
Sleep 2000000
'Fetch URL and Extract Protein Matches
Set rstsim = dbs.OpenRecordset("similarproteins", 2)
rstsim.MoveFirst
rstsim.MoveLast
rstsim.MoveFirst
Dim firstsim, nosim
firstsim = (rstsim.AbsolutePosition + 1)
nosim = (rstsim.RecordCount)
rstprot.MoveFirst
Dim CurrSearch, CodeStart, EValPreString, EValEndString, EValStart, EValEnd, TmpEVal
For z = firstprot To noprot
'Defines URL to retrieve
CurrProt = (rstprot.AbsolutePosition + 1)
fetchURL = JobURLs(CurrProt)
Set IE = CreateObject("InternetExplorer.Application"
IE.navigate fetchURL
Do While IE.Busy
Loop
Do While IE.ReadyState <> 4
Loop
'Takes data from webpage and puts it into var page
page = IE.Document.all.tags("html"
.Item(0).outerhtml
MsgBox (page)
Dim EValPrePreString As String
'Parse page for ProteinCodes, find E-Values, Trim E-Value, and Insert into rstprot
For a = firstsim To nosim
CurrSearch = "libview.cgi?id=" + rstsim!proteincode
CodeStart = InStr(1, page, CurrSearch)
If CodeStart <> 0 Then
EValPreString = "<td>"
EValPrePreString = "Chime View"
EValEndString = "</td>"
EValPreStart = InStr(CodeStart, page, EValPrePreString)
EValStart = InStr(EValPreStart, page, EValPreString)
EValEnd = InStr(EValStart, page, EValEndString)
TmpEVal = Mid(page, (EValStart + 4), (EValEnd - (EValStart + 4)))
'MsgBox (TmpEVal)
EValue = Trim(TmpEVal)
'MsgBox (EValue)
'Recordset.Fields (SearchString)
rstprot.Edit
rstprot.Fields(rstsim!proteincode) = EValue
rstprot.Update
End If
rstsim.MoveNext
Next a
rstprot.MoveNext
Next z
MsgBox (CleanedProts(1))
MsgBox (CleanedProts(2))
MsgBox (CleanedProts(3))
MsgBox (CleanedProts(4))
'dbs.OpenRecordset
'DoCmd.OpenTable "proteins"
End Sub
I just finished coding an Access sub. Every time I run it, it will go through the first iteration of the "For a = firstsim To nosim" loop and save all of the data correctly. But on the second iteration, it inexplicably stops and returns a 440 runtime error "Automation Error." Help just talks about there being an error in an "automation object." Does anyone have any clue as to what this might mean? If anyone has some spare time, would you mind looking taking a look at the code that follows and maybe give me some suggestions as to an error I'm missing?
Thank you so much!
Ben
----
Private Sub Command21_Click()
Dim Email
Email = InputBox("Please enter your e-mail address for 3DPSSM access.", "Enter e-mail address"
Set dbs = CurrentDb
Set rstprot = dbs.OpenRecordset("proteins", 2)
rstprot.MoveFirst
rstprot.MoveLast
MsgBox (rstprot.RecordCount)
Dim myvar, myvar2
myvar = "h234343*"
myvar2 = Split(myvar, "*", 2)
MsgBox (myvar2(0))
'Specify Min (firstprot) and Max (noprot) record numbers
Dim noprot
noprot = rstprot.RecordCount
Dim firstprot
rstprot.MoveFirst
firstprot = (rstprot.AbsolutePosition + 1)
'Array to store Prots to be sent through 3DPSSM
ReDim CleanedProts(noprot)
CleanedProts(0) = ""
'Loop to strip out stop codons
With rstprot
Dim protst, CleanProt, DirtyProtArray, DirtyProtArray2
Dim CurrProt
For x = firstprot To noprot
protst = !Sequence
DirtyProtArray = Split(protst, ".", 2)
CleanProt = DirtyProtArray(0)
DirtyProtArray2 = Split(CleanProt, "*", 2)
CleanProt = DirtyProtArray2(0)
CurrProt = (rstprot.AbsolutePosition + 1)
MsgBox (CurrProt)
CleanedProts(CurrProt) = CleanProt
.MoveNext
Next x
End With
MsgBox ("Before"
Sleep 3000
MsgBox ("3sec"
'Defines Array to store the URLs of the 3DPSSM jobs
ReDim JobURLs(noprot)
With rstprot
'Submit Loop
.MoveFirst
MsgBox ("submit for loop"
For y = firstprot To noprot
'Defines String to Submit
CurrProt = (.AbsolutePosition + 1)
submitstr = CleanedProts(CurrProt)
MsgBox (!ProteinID)
Dim IE
Dim page As String
Set IE = CreateObject("InternetExplorer.Application"
'Submit as URL
Dim JobURL(6), finalJobURL
JobURL(0) = " JobURL(1) = Email
JobURL(2) = "&seq-desc="
JobURL(3) = !ProteinID
JobURL(4) = "&seq_format=single&global_local=yes&seg=yes&DataFormat=yes&three_iter=no&sequence="
JobURL(5) = submitstr
finalJobURL = Join(JobURL)
IE.navigate finalJobURL
Do While IE.Busy
Loop
Do While IE.ReadyState <> 4
Loop
'Takes return data
page = IE.Document.all.tags("html"
Dim jstart, jend, jURL
jstart = InStr(1, page, "<br><a href=" + Chr(34))
jend = InStr(lstart + 1, page, Chr(34) + " target"
MsgBox (page)
If jstart <> 0 And jend <> 0 Then
jURL = (Mid(page, jstart + 13, (jend - 13) - (jstart + 13)) & ".summaryhits.html"
JobURLs(CurrProt) = jURL
MsgBox (jURL)
End If
.MoveNext
Next y
End With
MsgBox ("Your computer will now wait for 3DPSSM to process the data. While the computer is waiting, Access may appear to be frozen. Disregard these warnings"
Sleep 2000000
'Fetch URL and Extract Protein Matches
Set rstsim = dbs.OpenRecordset("similarproteins", 2)
rstsim.MoveFirst
rstsim.MoveLast
rstsim.MoveFirst
Dim firstsim, nosim
firstsim = (rstsim.AbsolutePosition + 1)
nosim = (rstsim.RecordCount)
rstprot.MoveFirst
Dim CurrSearch, CodeStart, EValPreString, EValEndString, EValStart, EValEnd, TmpEVal
For z = firstprot To noprot
'Defines URL to retrieve
CurrProt = (rstprot.AbsolutePosition + 1)
fetchURL = JobURLs(CurrProt)
Set IE = CreateObject("InternetExplorer.Application"
IE.navigate fetchURL
Do While IE.Busy
Loop
Do While IE.ReadyState <> 4
Loop
'Takes data from webpage and puts it into var page
page = IE.Document.all.tags("html"
MsgBox (page)
Dim EValPrePreString As String
'Parse page for ProteinCodes, find E-Values, Trim E-Value, and Insert into rstprot
For a = firstsim To nosim
CurrSearch = "libview.cgi?id=" + rstsim!proteincode
CodeStart = InStr(1, page, CurrSearch)
If CodeStart <> 0 Then
EValPreString = "<td>"
EValPrePreString = "Chime View"
EValEndString = "</td>"
EValPreStart = InStr(CodeStart, page, EValPrePreString)
EValStart = InStr(EValPreStart, page, EValPreString)
EValEnd = InStr(EValStart, page, EValEndString)
TmpEVal = Mid(page, (EValStart + 4), (EValEnd - (EValStart + 4)))
'MsgBox (TmpEVal)
EValue = Trim(TmpEVal)
'MsgBox (EValue)
'Recordset.Fields (SearchString)
rstprot.Edit
rstprot.Fields(rstsim!proteincode) = EValue
rstprot.Update
End If
rstsim.MoveNext
Next a
rstprot.MoveNext
Next z
MsgBox (CleanedProts(1))
MsgBox (CleanedProts(2))
MsgBox (CleanedProts(3))
MsgBox (CleanedProts(4))
'dbs.OpenRecordset
'DoCmd.OpenTable "proteins"
End Sub