Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1

    Default Need ure help in vb6.


    mga istoryan naay ko ask.

    Unsay pasabot anang USER-DEFINED TYPE NOT DEFINED error ni sa vb (sa module ako gibutang kay Public Conn as ADODB.Connection)with database MSHFlexgrid.
    i have my code in here, I need ure help. Sige kog balikbalik ani mao lang ghapon.

    i can send my code.

  2. #2
    Quote Originally Posted by reyarita View Post
    mga istoryan naay ko ask.

    Unsay pasabot anang USER-DEFINED TYPE NOT DEFINED error ni sa vb (sa module ako gibutang kay Public Conn as ADODB.Connection)with database MSHFlexgrid.
    i have my code in here, I need ure help. Sige kog balikbalik ani mao lang ghapon.

    i can send my code.
    it's an object if you use you have to instantiate first,

    you can write it this way:
    Public Conn as new ADODB.Connection

    or

    Conn = new ADODB.Connection


    I hope it helps

  3. #3
    ok i try it.

    dili man

    this is my code :

    ================================================== ==============================
    Dim newEdit As Byte


    Private Sub cmdCancel_Click()
    clearTextboxes
    defaultMode
    End Sub

    Private Sub cmdDelete_Click()
    Dim ans As Byte
    ans = MsgBox("Do you want to delete this record?", vbYesNo, "Delete")
    If ans = vbYes Then
    Dim rs As New ADODB.Recordset
    rs.Open "Delete From Student Where Stud_id='" & txtID.Text & "'", Conn, adOpenDynamic, adLockOptimistic
    MsgBox "One Record Deleted."
    End If
    defaultMode
    clearTextboxes
    End Sub

    Private Sub cmdEdit_Click()
    controlTextBoxes (True)
    controlButtons (False)
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    newEdit = 1
    txtLname.SetFocus
    End Sub

    Private Sub cmdNew_Click()
    controlTextBoxes (True)
    clearTextboxes
    txtID.SetFocus
    controlButtons (False)
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    newEdit = 0
    End Sub

    Function clearTextboxes()
    txtID = ""
    txtLname = ""
    txtFname = ""
    txtMname = ""
    txtCourse = ""
    txtYear = ""
    cboBirth = ""
    txtAddress = ""
    End Function

    Private Sub cmdSave_Click()
    controlButtons (False)
    controlTextBoxes (False)
    cmdNew.Enabled = True
    cmdSearch.Enabled = True
    cmdCancel.Enabled = True

    Dim rs As New ADODB.Recordset
    Dim sqlStr As String
    If newEdit = 0 Then
    sqlStr = "Select * From Student Where Stud_id='" & txtID.Text & "'"
    rs.Open sqlStr, Conn, adOpenDynamic, adLockOptimistic
    If rs.EOF Then
    With rs
    .Addnew
    !Stud_id = txtID.Text
    !Stud_lname = txtLname.Text
    !Stud_fname = txtFname.Text
    !Stud_mname = txtMname.Text
    !Stud_course = txtCourse.Text
    !Stud_year = txtYear.Text
    !Stud_address = txtAddress.Text
    !Stud_DOB = cboBirth.Text
    .Update
    End With
    MsgBox "Record was been save!"
    Else
    MsgBox "ERROR: Duplicate ID Number!"
    End If

    Else
    sqlStr = "Select * From Student Where Stud_id='" & txtID.Text & "'"
    rs.Open sqlStr, Conn, adOpenDynamic, adLockOptimistic
    With rs
    !Stud_id = txtID.Text
    !Stud_lname = txtLname.Text
    !Stud_fname = txtFname.Text
    !Stud_mname = txtMname.Text
    !Stud_course = txtCourse.Text
    !Stud_year = txtYear.Text
    !Stud_address = txtAddress.Text
    !Stud_DOB = cboBirth.Text
    .Update
    End With
    MsgBox "Record was been Updated!"
    End If
    rs.Close
    Set rs = Nothing
    populateFlexGrid
    End Sub

    Private Sub cmdSearch_Click()
    lblSearch.Visible = True
    txtSearch.Visible = True
    txtSearch.SetFocus
    End Sub

    Private Sub txtSearch_Change()
    Dim rs As New ADODB.Recordset
    sqlStr = "Select Stud_id,Stud_id,Stud_lname,Stud_fname,Stud_mname From Student Where Stud_lname Like '" & txtSearch.Text & "%' Order by Stud_lname"
    rs.Open sqlStr, Conn, adOpenForwardOnly, adLockReadOnly
    Set MSHStudent.Recordset = rs
    rs.Close
    End Sub

    Private Sub Form_Load()
    Set Conn = New ADODB.Connection
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "StudInfo.mdb" & ";Persist Security Info=False"
    Conn.Open
    Conn.CursorLocation = adUseClient
    newEdit = 0
    defaultMode
    End Sub

    Function defaultMode()
    populateFlexGrid
    controlButtons (False)
    controlTextBoxes (False)
    cmdNew.Enabled = True
    cmdSearch.Enabled = True
    cmdCancel.Enabled = True
    End Function

    Function controlButtons(flag)
    cmdNew.Enabled = flag
    cmdSave.Enabled = flag
    cmdEdit.Enabled = flag
    cmdDelete.Enabled = flag
    cmdSearch.Enabled = flag
    cmdCancel.Enabled = flag
    End Function

    Function controlTextBoxes(flag)
    txtID.Enabled = flag
    txtLname.Enabled = flag
    txtFname.Enabled = flag
    End Function

    Function populateFlexGrid()
    Dim rs As New ADODB.Recordset
    Dim sqlStr As String
    sqlStr = "SELECT Stud_id,Stud_id,Stud_lname,Stud_fname from Student Order by Stud_lname"
    rs.Open sqlStr, Conn, adOpenForwardOnly, adLockReadOnly
    If Not rs.EOF Then
    MSHStudent.FixedCols = 0
    Set MSHStudent.Recordset = rs
    With MSHStudent
    .FormatString = "ID|ID Number|Last Name|First Name"
    .ColWidth(0) = 0
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
    .ColWidth(3) = 2500
    .AllowUserResizing = flexResizeColumns
    .SelectionMode = flexSelectionByRow
    End With
    MSHStudent.Enabled = True
    Else
    MSHStudent.FixedCols = 0
    With MSHStudent
    .FormatString = "ID|ID Number|Last Name|First Name"
    .ColWidth(0) = 0
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
    .ColWidth(3) = 2500
    MSHStudent.TextMatrix(1, 1) = ""
    MSHStudent.TextMatrix(1, 2) = ""
    MSHStudent.TextMatrix(1, 3) = ""
    End With
    MSHStudent.Enabled = False
    End If
    End Function

    Private Sub MSHStudent_Click()
    txtID.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 1)
    txtLname.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 2)
    txtFname.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 3)
    controlButtons (False)
    cmdEdit.Enabled = True
    cmdDelete.Enabled = True
    cmdCancel.Enabled = True
    End Sub

    Private Sub MSHStudent_KeyDown(KeyCode As Integer, Shift As Integer)
    MSHStudent_Click
    End Sub


    ================================================== =============================
    Sa ako module mao ni

    Public Conn As New ADODB.Connection
    ================================================== =============================
    dili man gihapon

  4. #4
    something like this..

    in your connection.bas module to make it global

    Public rsnext As New ADODB.Recordset

  5. #5
    Quote Originally Posted by reyarita View Post
    ok i try it.

    dili man

    this is my code :

    ================================================== ==============================
    Dim newEdit As Byte


    Private Sub cmdCancel_Click()
    clearTextboxes
    defaultMode
    End Sub

    Private Sub cmdDelete_Click()
    Dim ans As Byte
    ans = MsgBox("Do you want to delete this record?", vbYesNo, "Delete")
    If ans = vbYes Then
    Dim rs As New ADODB.Recordset
    rs.Open "Delete From Student Where Stud_id='" & txtID.Text & "'", Conn, adOpenDynamic, adLockOptimistic
    MsgBox "One Record Deleted."
    End If
    defaultMode
    clearTextboxes
    End Sub

    Private Sub cmdEdit_Click()
    controlTextBoxes (True)
    controlButtons (False)
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    newEdit = 1
    txtLname.SetFocus
    End Sub

    Private Sub cmdNew_Click()
    controlTextBoxes (True)
    clearTextboxes
    txtID.SetFocus
    controlButtons (False)
    cmdSave.Enabled = True
    cmdCancel.Enabled = True
    newEdit = 0
    End Sub

    Function clearTextboxes()
    txtID = ""
    txtLname = ""
    txtFname = ""
    txtMname = ""
    txtCourse = ""
    txtYear = ""
    cboBirth = ""
    txtAddress = ""
    End Function

    Private Sub cmdSave_Click()
    controlButtons (False)
    controlTextBoxes (False)
    cmdNew.Enabled = True
    cmdSearch.Enabled = True
    cmdCancel.Enabled = True

    Dim rs As New ADODB.Recordset
    Dim sqlStr As String
    If newEdit = 0 Then
    sqlStr = "Select * From Student Where Stud_id='" & txtID.Text & "'"
    rs.Open sqlStr, Conn, adOpenDynamic, adLockOptimistic
    If rs.EOF Then
    With rs
    .Addnew
    !Stud_id = txtID.Text
    !Stud_lname = txtLname.Text
    !Stud_fname = txtFname.Text
    !Stud_mname = txtMname.Text
    !Stud_course = txtCourse.Text
    !Stud_year = txtYear.Text
    !Stud_address = txtAddress.Text
    !Stud_DOB = cboBirth.Text
    .Update
    End With
    MsgBox "Record was been save!"
    Else
    MsgBox "ERROR: Duplicate ID Number!"
    End If

    Else
    sqlStr = "Select * From Student Where Stud_id='" & txtID.Text & "'"
    rs.Open sqlStr, Conn, adOpenDynamic, adLockOptimistic
    With rs
    !Stud_id = txtID.Text
    !Stud_lname = txtLname.Text
    !Stud_fname = txtFname.Text
    !Stud_mname = txtMname.Text
    !Stud_course = txtCourse.Text
    !Stud_year = txtYear.Text
    !Stud_address = txtAddress.Text
    !Stud_DOB = cboBirth.Text
    .Update
    End With
    MsgBox "Record was been Updated!"
    End If
    rs.Close
    Set rs = Nothing
    populateFlexGrid
    End Sub

    Private Sub cmdSearch_Click()
    lblSearch.Visible = True
    txtSearch.Visible = True
    txtSearch.SetFocus
    End Sub

    Private Sub txtSearch_Change()
    Dim rs As New ADODB.Recordset
    sqlStr = "Select Stud_id,Stud_id,Stud_lname,Stud_fname,Stud_mname From Student Where Stud_lname Like '" & txtSearch.Text & "%' Order by Stud_lname"
    rs.Open sqlStr, Conn, adOpenForwardOnly, adLockReadOnly
    Set MSHStudent.Recordset = rs
    rs.Close
    End Sub

    Private Sub Form_Load()
    Set Conn = New ADODB.Connection
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "StudInfo.mdb" & ";Persist Security Info=False"
    Conn.Open
    Conn.CursorLocation = adUseClient
    newEdit = 0
    defaultMode
    End Sub

    Function defaultMode()
    populateFlexGrid
    controlButtons (False)
    controlTextBoxes (False)
    cmdNew.Enabled = True
    cmdSearch.Enabled = True
    cmdCancel.Enabled = True
    End Function

    Function controlButtons(flag)
    cmdNew.Enabled = flag
    cmdSave.Enabled = flag
    cmdEdit.Enabled = flag
    cmdDelete.Enabled = flag
    cmdSearch.Enabled = flag
    cmdCancel.Enabled = flag
    End Function

    Function controlTextBoxes(flag)
    txtID.Enabled = flag
    txtLname.Enabled = flag
    txtFname.Enabled = flag
    End Function

    Function populateFlexGrid()
    Dim rs As New ADODB.Recordset
    Dim sqlStr As String
    sqlStr = "SELECT Stud_id,Stud_id,Stud_lname,Stud_fname from Student Order by Stud_lname"
    rs.Open sqlStr, Conn, adOpenForwardOnly, adLockReadOnly
    If Not rs.EOF Then
    MSHStudent.FixedCols = 0
    Set MSHStudent.Recordset = rs
    With MSHStudent
    .FormatString = "ID|ID Number|Last Name|First Name"
    .ColWidth(0) = 0
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
    .ColWidth(3) = 2500
    .AllowUserResizing = flexResizeColumns
    .SelectionMode = flexSelectionByRow
    End With
    MSHStudent.Enabled = True
    Else
    MSHStudent.FixedCols = 0
    With MSHStudent
    .FormatString = "ID|ID Number|Last Name|First Name"
    .ColWidth(0) = 0
    .ColWidth(1) = 1500
    .ColWidth(2) = 2500
    .ColWidth(3) = 2500
    MSHStudent.TextMatrix(1, 1) = ""
    MSHStudent.TextMatrix(1, 2) = ""
    MSHStudent.TextMatrix(1, 3) = ""
    End With
    MSHStudent.Enabled = False
    End If
    End Function

    Private Sub MSHStudent_Click()
    txtID.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 1)
    txtLname.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 2)
    txtFname.Text = MSHStudent.TextMatrix(MSHStudent.RowSel, 3)
    controlButtons (False)
    cmdEdit.Enabled = True
    cmdDelete.Enabled = True
    cmdCancel.Enabled = True
    End Sub

    Private Sub MSHStudent_KeyDown(KeyCode As Integer, Shift As Integer)
    MSHStudent_Click
    End Sub


    ================================================== =============================
    Sa ako module mao ni

    Public Conn As New ADODB.Connection
    ================================================== =============================
    dili man gihapon
    bro. dili mn ko maka pa run ani imong code, wala pud ko time, pwde imo e e-mail sa akong ang actual file?

    imo namn kaha gi check kung naka referrence ang ADODB object? sa imong reference files

    Asa jud dapit sa code ang mo highlight if mo error?

  6. #6
    Case Closed.. !!! ^_^ hheheeheheh

    mana solbad guys!!!

  7. #7
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    Add your components or "CTRL-T", add Microsoft ADO data control, and some desired components you will be using.

  8. #8
    salamat sa inyong tabang especially vash_guy

  9. #9
    mapatabang ya ko ninyo sunod
    mga istoryaniks

  10. #10
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    LOL... if you followed my advice i'm sure you got it right.

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Looking For: Need some help in configuring my prolink H6300G
    By aldwin in forum Computers & Accessories
    Replies: 1
    Last Post: 02-23-2011, 09:03 PM
  2. i need ur help in query sa vb
    By skeptic_rob in forum Programming
    Replies: 15
    Last Post: 12-31-2010, 10:38 PM
  3. help in VB6
    By ingkiang in forum Programming
    Replies: 8
    Last Post: 08-26-2009, 04:47 PM
  4. Need help in VB6
    By nirdle_phogi in forum Programming
    Replies: 5
    Last Post: 03-13-2007, 12:45 AM
  5. i need some help in using DREAMweaver please.
    By staT|c-X in forum Software & Games (Old)
    Replies: 0
    Last Post: 01-27-2007, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top