Results 1 to 5 of 5

Thread: Vb6 Help!!!

  1. #1
    Join Date
    Mar 2004
    Location
    manila, philippines
    Posts
    3

    Angry Unanswered: Vb6 Help!!!

    Everything about VB6 errors... How to debug

  2. #2
    Join Date
    Mar 2004
    Location
    manila, philippines
    Posts
    3

    Error in From Clause

    Can you please help me on this one... the program is having an error with the from clause... please help any kind of help will be very much appreciated

    Option Explicit
    Dim add As Boolean
    Dim Update As Boolean
    Private Sub cmdAdd_Click()
    add = True
    UnlockTxt
    ClearTxt
    DisableButton
    End Sub

    Private Sub cmdCancel_Click()
    Dim rs As New ADODB.Recordset

    add = False
    Update = False

    ClearTxt
    LockTxt
    EnableButton

    With rs
    .Open "Select * From tblRetreat", cn, adOpenKeyset, adLockOptimistic
    If Not .EOF Then
    LoadRecord
    Else
    cmdUpdate.Enabled = False
    cmdDelete.Enabled = False
    frmeSearch.Enabled = False
    dgRetreat.Enabled = False
    End If
    .Close
    End With
    Set rs = Nothing

    End Sub

    Private Sub cmdDelete_Click()
    Dim rs As New ADODB.Recordset
    With rs
    .Open "Select * From tblRetreat", cn, adOpenKeyset, adLockOptimistic
    If Not .EOF Then
    .Delete
    .MoveNext
    ClearTxt
    End If
    .Close
    .Open "Select * From tblRetreat", cn, adOpenKeyset, adLockBatchOptimistic
    If Not .EOF Then
    LoadRecord
    Else
    cmdUpdate.Enabled = False
    cmdDelete.Enabled = False
    frmeSearch.Enabled = False
    dgRetreat.Enabled = False
    End If
    .Close
    End With
    Set rs = Nothing
    adoRetreat.Refresh
    End Sub

    Private Sub cmdPrint_Click()
    With DataEnvironment.rstblRetreat
    If .State = 1 Then
    .Close
    End If
    End With
    DataEnvironment1.Retreat (txtRetHsName)

    End Sub

    Private Sub cmdSave_Click()
    Dim rs As New ADODB.Recordset

    With rs
    .Open "Select * From tblRetreat Where RetreatHouseName = '" & txtRetHsName & "'", cn, adOpenKeyset, adLockOptimistic
    If add Then
    If Not .EOF Then
    MsgBox " Record already exists", vbInformation
    Exit Sub
    Else
    cn.BeginTrans
    .AddNew
    rs!RetreatHouseName = txtRetHsName.Text
    rs!RetreatAddress = txtRetAddrs.Text
    rs!RetreatContactNo = txtRetContact.Text
    rs!RetreatEmail = txtRetEmail.Text
    .Update
    cn.CommitTrans

    End If
    ElseIf Update Then
    If Not .EOF Then
    cn.BeginTrans
    rs!RetreatHouseName = txtRetHsName.Text
    rs!RetreatAddress = txtRetAddrs.Text
    rs!RetreatContactNo = txtRetContact.Text
    rs!RetreatEmail = txtRetEmail.Text
    .Update
    cn.CommitTrans
    Else
    MsgBox "Record doesn't exists! ", vbInformation
    Exit Sub
    End If
    End If
    .Close
    End With
    Set rs = Nothing
    ClearTxt
    LockTxt
    adoRetreat.Refresh
    LoadRecord
    End Sub

    Private Sub cmdUpdate_Click()
    Update = True
    UnlockTxt
    DisableButton
    End Sub

    Private Sub dgRetreat_Click()
    Dim rs As New ADODB.Recordset

    With dgRetreat
    txtRetHsName.Text = .Columns(0)
    txtRetAddrs.Text = .Columns(1)
    txtRetContact.Text = .Columns(2)
    txtRetEmail.Text = .Columns(3)
    End With

    cmdSave.Enabled = False
    txtSearch.Text = ""
    End Sub

    Private Sub Form_Activate()
    adoRetreat.ConnectionString = cn
    adoRetreat.RecordSource = "Select * From tblRetreat"
    adoRetreat.Refresh
    End Sub

    Private Sub Form_Initialize()
    With frmRetreat
    .Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
    End With
    End Sub

    Private Sub Form_Load()
    Dim rs As New ADODB.Recordset
    With rs
    .Open "SELECT * From tblRetreat", cn, adOpenKeyset, adLockOptimistic
    If Not .EOF Then
    LoadRecord
    Else

    cmdUpdate.Enabled = False
    cmdDelete.Enabled = False
    frmeSearch.Enabled = False
    dgRetreat.Enabled = False

    End If
    .Close
    End With

    Set rs = Nothing
    add = False
    Update = False
    End Sub
    Sub LoadRecord()
    Dim rs As New ADODB.Recordset

    With rs
    .Open "Select * From tblRetreat", cn, adOpenKeyset, adLockOptimistic

    If Not .EOF Then
    .MoveFirst
    txtRetHsName.Text = rs!RetreatHouseName
    txtRetAddrs.Text = rs!RetreatAddress
    txtRetContact.Text = rs!RetreatContactNo
    txtRetEmail.Text = rs!RetreatEmail
    End If
    .Close
    End With
    Set rs = Nothing
    cmdSave.Enabled = False
    End Sub
    Sub ClearTxt()
    txtRetHsName = ""
    txtRetAddrs = ""
    txtRetContact = ""
    txtRetEmail = ""
    End Sub
    Sub LockTxt()
    txtRetHsName.Locked = True
    txtRetAddrs.Locked = True
    txtRetContact.Locked = True
    txtRetEmail.Locked = True
    End Sub
    Sub UnlockTxt()
    txtRetHsName.Locked = False
    txtRetAddrs.Locked = False
    txtRetContact.Locked = False
    txtRetEmail.Locked = False
    End Sub
    Sub EnableButton()
    cmdAdd.Enabled = True
    cmdUpdate.Enabled = True
    cmdDelete.Enabled = True
    cmdSave.Enabled = False
    cmdCancel.Enabled = False
    frmeSearch.Enabled = True
    dgRetreat.Enabled = True
    End Sub
    Sub DisableButton()
    cmdAdd.Enabled = False
    cmdUpdate.Enabled = False
    cmdDelete.Enabled = False
    cmdCancel.Enabled = True
    frmeSearch.Enabled = False
    dgRetreat.Enabled = False
    End Sub


    Private Sub txtRetAddrs_Change()
    txtRetHsName_Change
    End Sub

    Private Sub txtRetAddrs_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    SendKeys "{tab}"
    End If
    End Sub

    Private Sub txtRetContact_Change()
    txtRetHsName_Change
    End Sub

    Private Sub txtRetContact_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    SendKeys "{tab}"
    End If
    End Sub

    Private Sub txtRetEmail_Change()
    txtRetHsName_Change
    End Sub

    Private Sub txtRetEmail_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    SendKeys "{tab}"
    End If
    End Sub

    Private Sub txtRetHsName_Change()
    If Not txtRetHsName.Text = "" And Not txtRetAddrs.Text = "" _
    And Not txtRetContact.Text = "" And Not txtRetEmail.Text = "" Then
    cmdSave.Enabled = True
    Else
    cmdSave.Enabled = False
    End If
    End Sub

    Private Sub txtRetHsName_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    SendKeys "{tab}"
    End If
    End Sub

    Private Sub txtSearch_Change()
    adoRetreat.RecordSource = "Select * From tblRetreat Where RetreatHouseName like '" & txtRetreatHouseName & "%' Order by RetreatHouseName"
    adoRetreat.Refresh
    End Sub

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54

    Re: Error in From Clause

    Which from clause? What problem?

    -PatP

  4. #4
    Join Date
    Mar 2004
    Location
    manila, philippines
    Posts
    3

    Re: Error in From Clause

    Originally posted by Pat Phelan
    Which from clause? What problem?

    -PatP
    in the form activate :

    adoRetreat.RecordSource = "Select * From tblRetreat Order By RetreatHouseName"
    adoRetreat.Refresh

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I don't think you've connected to a database. You can't retrieve much until after you connect.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •