Results 1 to 7 of 7

Thread: [RESOLVED] Is this the only way

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    114

    Resolved [RESOLVED] Is this the only way

    HELLO!
    Is there any other way I could populate my text boxes and cbo on my form?

    Public Sub fillfields()

    'cboPconsonants.AddItem rs.Fields("Pconsonants")
    txtStudentln.Text = rs.Fields("firstname"): txtStudentfn.Text = rs.Fields("lastname"): txtStudentID.Text = rs.Fields("ID")
    Pconsonants.Text = rs.Fields("Pconsonants")

    End Sub


    I have 58 items that need to show data. Do I have to put them all in the fillfields section? Please is there another way.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Is this the only way

    on the textbox datafield property enter the datafield

    dim ctrl as control
    for each ctrl in controls
    if typeof ctrl is textbox and not trim(ctrl.datafield) ="" then
    ctrl.text=rs.fields(ctrl.datafield)
    end if
    next ctrl

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    114

    Re: Is this the only way

    First of all thanks for the quick reply. I understand where to put the dim statement but I'm exactly sure where the rest of code would go. Could you please explain. Oh yeah I'm new to VB if you couldn't figure that out. By the way I am not using any data controls so there is nothing in the textbox data field.
    Last edited by graphixphantix; Feb 18th, 2006 at 01:08 AM.

  4. #4
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Is this the only way

    you can assign a datafield in a textbox without datacontrols... or you can use tags

    on the textbox tag property enter the datafield

    dim ctrl as control
    for each ctrl in controls
    if typeof ctrl is textbox and not trim(ctrl.tag) ="" then
    ctrl.text=rs.fields(ctrl.tag)
    end if
    next ctrl

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    114

    Re: Is this the only way

    Thanks! that worked great but how do I apply that to my combo boxes....just replace the textbox with combobox

    For Each ctrl In Controls
    If TypeOf ctrl Is TextBox And Not Trim(ctrl.Tag) = "" Then
    ctrl.Text = rs.Fields(ctrl.Tag)
    End If
    Next ctrl



    I also trid to put rs.update to save changes when I click next but when I used previous button to go back it still had old values.

  6. #6
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Is this the only way

    I understand where to put the dim statement but I'm exactly sure where the rest of code would go. Could you please explain
    what action are you trying to do??? you can set the datasouce of the text box to your recordset

    dim ctrl as control
    for each ctrl in controls
    if typeof ctrl is textbox and not trim(ctrl.tag) ="" then
    set ctrl.datasource=rs
    ctrl.datafield=rs.fields(ctrl.tag)
    end if
    next ctrl


    and in popoulating a combobox
    do while not rs.eof
    combo1.additem rs.fields("pconsonant").
    rs.movenext
    loop

  7. #7
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Is this the only way

    I also trid to put rs.update to save changes when I click next but when I used previous button to go back it still had old values.
    check your recordset locktype
    rs.LockType = adLockOptimistic

Posting Permissions

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



Click Here to Expand Forum to Full Width