CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Location
    Alberta, Canada
    Posts
    7

    Sequential Access

    Here's what I got.
    Two forms. The first form has a drop-down menu (Clients) with items "add, edit and delete". these three access a client form with txtboxes to enter their info. When you click the "add" item you get an inputbox for a record number. If you enter a # that already exists you get an error message. Edit and delete also get you a blank client form.
    This is what I need.
    For the txtboxes to be filled in with the info of existing clients when you click edit or delete and the txtrecord box to have the number that the user enters in the inputbox when they click add.



    Chris

  2. #2
    Join Date
    Apr 2001
    Location
    Wisconsin, USA
    Posts
    150

    Re: Sequential Access

    Ok. For starters, I am sure you already have your connection set up. And then you have to retrieve your recordset (with all the items you want) based on the client ID entered in the txtRecord box. Then you just need to set the text property of all the other text boxes with the information you retrieved. Kinda looks like this:

    dim oConn as New ADODB.Connection
    dim RecSet1 as New ADODB.Recordset

    'We will just deal with the Edit for now, although the delete will work almost the same way.

    With oConn
    .ActiveConnection="dsn=Martins" 'or whatever the name is
    End With

    dim gsquery as String = "Select * from table where clientid = '" & txtClientID.text & "'"

    RecSet1.open gsquery

    RecSet1.MoveFirst
    if RecSet1.EOF then
    ' Display the appropriate message
    Exit sub
    end if

    txtName.text = RecSet1!Name

    And so on, with all the text fields. Now, you will have to make some adjustments, based upon the actual dsn you have set up, and the text field names you are using. Also, this will be inside a particular subroutine. If you want this to happen when you click a button to find the client, it will be in the button_click sub. If you want this to happen when the clientid text field loses focus, this will be in the lostFocus subroutine. does this help? You can email me at [email protected] if you need any additional help or clarification.


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

Featured