I have a VB form (VB6.0 Enterprise) with several textboxes and command buttons for Add, Delete, Update & Refresh. I also have a command button "cmdGo" that when clicked, should open Interent Explorer browser and go to the site that is listed in "txtField(2)". When I click on "GO" command button, what I get instead though, is the error message that I placed into my program "Error displaying file for web site". I cannot get to any websites.
I have a second form that is linked to a .mdb file that holds the website names and URLs that I created using VisData (I do NOT have Access at home, so VisData will do fine for this.) It's at this .mdb that I store the website names, which show up on my main form in txtField(0) with the URL being in txtField(1). The DataField for txtField(2) is set to pick-up whatever is in txtField(1), with txtField(1) having the complete URL. Therefore, all of the connections/relationships are correct.
Below is the code. Can you find where the problem(s) is/are? All of the features work great, except connecting to the internet when pressing the "Go" command button [Private Sub cmdGo_Click()].
Thanks.
Option Explicit
Dim varBookMark As Variant
Public Explorer As SHDocVwCtl.InternetExplorer
Private Sub Adodc1_MoveComplete(ByVal adReason As.EventReasonEnum, _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
lblRecord.Caption = "Record: " & _
CStr(Adodc1.Recordset.AbsolutePosition) & _
" of " & Str(Adodc1.Recordset.RecordCount)
End Sub
Private Sub cmdAction_Click(Index As Integer)
On Error GoTo goActionErr
With Adodc1
Select Case Index
Case 0 'Add
If cmdAction(0).Caption = "&Add" Then
varBookMark = .Recordset.Bookmark
.Recordset.AddNew
txtField(0).SetFocus
cmdAction(0).Caption = "&Cancel"
SetVisible False
Else
.Recordset.CancelUpdate
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveFirst
End If
cmdAction(Index).Caption = "&Add"
SetVisible True
End If
Case 1 'Delete
If .Recordset.EditMode = False Then
.Recordset.Delete
.Recordset.MoveNext
If .Recordset.EOF Then .Recordset.MoveLast
Else
MsgBox "Must update or refresh record before deleting!"
End If
Case 2 'Update
.Recordset.Update
varBookMark = .Recordset.Bookmark
.Recordset.Requery
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveLast
End If
cmdAction(0).Caption = "&Add"
SetVisible True
Case 3 'Refresh
varBookMark = .Recordset.Bookmark
.Refresh
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveLast
End If
End Select
End With
Exit Sub
goActionErr:
MsgBox Err.Description
End Sub
Private Sub cmdExit_Click()
Unload Me
Set frmSecret = Nothing
End Sub
Private Sub cmdGo_Click()
On Error GoTo Errorhandler
Set Explorer = New SHDocVwCtl.InternetExplorer
Explorer.Visible = True
Explorer.Navigate txtField(2)
Exit Sub
Errorhandler:
MsgBox "Error displaying file for web site"
End Sub
Private Sub cmdGrid_Click()
Secret_Web_Sites.Show
End Sub
Private Sub cmdNegotiate_Click(Index As Integer)
On Error GoTo goNegotiateErr
With Adodc1.Recordset
Select Case Index
Case 0 'First Record
.MoveFirst
Case 1 'Previous Record
.MovePrevious
If .BOF Then .MoveFirst
Case 2 'Next Record
.MoveNext
If .EOF Then .MoveLast
Case 3 'Last Record
.MoveLast
End Select
End With
Exit Sub
goNegotiateErr:
MsgBox Err.Description
End Sub
Public Sub SetVisible(blnStatus As Boolean)
Dim intIndex As Integer
For intIndex = 0 To 3
cmdNegotiate(intIndex).Enabled = blnStatus
Next intIndex
cmdAction(1).Enabled = blnStatus 'Delete
cmdAction(3).Enabled = blnStatus 'Refresh
End Sub
I have a second form that is linked to a .mdb file that holds the website names and URLs that I created using VisData (I do NOT have Access at home, so VisData will do fine for this.) It's at this .mdb that I store the website names, which show up on my main form in txtField(0) with the URL being in txtField(1). The DataField for txtField(2) is set to pick-up whatever is in txtField(1), with txtField(1) having the complete URL. Therefore, all of the connections/relationships are correct.
Below is the code. Can you find where the problem(s) is/are? All of the features work great, except connecting to the internet when pressing the "Go" command button [Private Sub cmdGo_Click()].
Thanks.
Option Explicit
Dim varBookMark As Variant
Public Explorer As SHDocVwCtl.InternetExplorer
Private Sub Adodc1_MoveComplete(ByVal adReason As.EventReasonEnum, _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
lblRecord.Caption = "Record: " & _
CStr(Adodc1.Recordset.AbsolutePosition) & _
" of " & Str(Adodc1.Recordset.RecordCount)
End Sub
Private Sub cmdAction_Click(Index As Integer)
On Error GoTo goActionErr
With Adodc1
Select Case Index
Case 0 'Add
If cmdAction(0).Caption = "&Add" Then
varBookMark = .Recordset.Bookmark
.Recordset.AddNew
txtField(0).SetFocus
cmdAction(0).Caption = "&Cancel"
SetVisible False
Else
.Recordset.CancelUpdate
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveFirst
End If
cmdAction(Index).Caption = "&Add"
SetVisible True
End If
Case 1 'Delete
If .Recordset.EditMode = False Then
.Recordset.Delete
.Recordset.MoveNext
If .Recordset.EOF Then .Recordset.MoveLast
Else
MsgBox "Must update or refresh record before deleting!"
End If
Case 2 'Update
.Recordset.Update
varBookMark = .Recordset.Bookmark
.Recordset.Requery
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveLast
End If
cmdAction(0).Caption = "&Add"
SetVisible True
Case 3 'Refresh
varBookMark = .Recordset.Bookmark
.Refresh
If varBookMark > 0 Then
.Recordset.Bookmark = varBookMark
Else
.Recordset.MoveLast
End If
End Select
End With
Exit Sub
goActionErr:
MsgBox Err.Description
End Sub
Private Sub cmdExit_Click()
Unload Me
Set frmSecret = Nothing
End Sub
Private Sub cmdGo_Click()
On Error GoTo Errorhandler
Set Explorer = New SHDocVwCtl.InternetExplorer
Explorer.Visible = True
Explorer.Navigate txtField(2)
Exit Sub
Errorhandler:
MsgBox "Error displaying file for web site"
End Sub
Private Sub cmdGrid_Click()
Secret_Web_Sites.Show
End Sub
Private Sub cmdNegotiate_Click(Index As Integer)
On Error GoTo goNegotiateErr
With Adodc1.Recordset
Select Case Index
Case 0 'First Record
.MoveFirst
Case 1 'Previous Record
.MovePrevious
If .BOF Then .MoveFirst
Case 2 'Next Record
.MoveNext
If .EOF Then .MoveLast
Case 3 'Last Record
.MoveLast
End Select
End With
Exit Sub
goNegotiateErr:
MsgBox Err.Description
End Sub
Public Sub SetVisible(blnStatus As Boolean)
Dim intIndex As Integer
For intIndex = 0 To 3
cmdNegotiate(intIndex).Enabled = blnStatus
Next intIndex
cmdAction(1).Enabled = blnStatus 'Delete
cmdAction(3).Enabled = blnStatus 'Refresh
End Sub