DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    May 2007

    i'm vry new to vb..emergency help plz

    hi every1...i'm very new to VB programing...i got an assignment that i have to develop an application with VB6 & MS-Access..but i'm stock in some points:

    1.i have a register button in my form...when it is pressed, the registation form opens, which is connected to my access database...so it shows the inserted data inside my access table...BUT I WANT A FRESH PAGE (empty form)TO ALLOW USERS INSERT DATA...

    2.in my registeration form, there is 1 password textbox and also 1 confirm password textbox...HOW CAN I CODE THE CONFIRM PASSWORD TEXTBOX THAT IF IT IS DIFFRENT WITH THE CHOOSEN PASSWORD, A LABLE APPEARS ON TOP OF REGISTRATION FORM TO INFORM USER.???

    3.how can i connect a combo box to show the items(for example:name of countries)

    any help appritiated...but plz when u answer, mention the exact answer (for example, if i need to change anything in the code or where should i insert...bcz i'm very new to VB")...

    tnx in advance...
    Last edited by kasra100; 05-06-2007 at 07:13 PM.

  2. #2
    Join Date
    Sep 2005
    We don't generally help people with their homework assignments. I would suggest being a little more discreet.
    For your second question you can add a form and choose the login dialog box. It has the built-in capability to detect a wrong password. This is the code that you will see if you add this type of form...
    Public LoginSucceeded As Boolean
    Private Sub cmdCancel_Click()
        'set the global var to false
        'to denote a failed login
        LoginSucceeded = False
    End Sub
    Private Sub cmdOK_Click()
        'check for correct password
        If txtPassword = "password" Then ' put your password you want the user to select here        'place code to here to pass the
            'success to the calling sub
            'setting a global var is the easiest
            LoginSucceeded = True
            MsgBox "Invalid Password, try again!", , "Login"
            SendKeys "{Home}+{End}"
        End If
    End Sub
    This should get you started

  3. #3
    Join Date
    May 2007
    dear RipIT..tnx alot for ur reply..
    but the case is a quiet diffrent (bcz i didn't explain vry well)..
    c, the first page is the place where user can insert username and password and and enters to the application (with user validation)...but if the user is not registerd, he/she can click on register button to register in a blank registration form..how can i make that registration form blank..so user can insert data into table(ms access)...

    tnx again

  4. #4
    Join Date
    Aug 2004
    Orange, California
    You have several choices. You can use what are typically called Unbound controls. These are not linked to the database directly. They just hold the users input and of course would start off blank. You would then have to code the process of adding a new record, use a recordset, and assign each field it's value from the appropriate text box. Then you tell the recordset to update the database. Of course you will have to validate the users data, and make sure they are not already registered, no duplicate users.
    Another way is to use the Forms Load event and tell the recordset, or data control, which ever you are using, to go to a new record. This way the form is always on a new record when it is opened.
    Also there are more than on way to load a list into a combo box. There are several examples in VB's help. Open the help and search on combo box control. Click on the Location Column Header within the search results. This will sort by location. Then just scroll down to the Visual Basic Concepts Section. There you will find several examples of how to use the combo box control. Also look into the DataCombo control as well. It allows you to use a recordset to load the list. You can also pre-load the list manually by entering the items into the List property of the standard combo box control.

  5. #5
    Join Date
    May 2007

    I Got Stuck Again...

    hi every1...
    can any1 help me figure out how....
    in my form, there is a textbox to input PROPERTY ID and get the required data...there is also a browse button beside that...assume that when it is pressed, some selected field of table with ALL their items appear in a FRAME LIST...how can i do that????????


  6. #6
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    How are you connecting to your database?

    ADO Code (hopefully)
    ADODC bound data control

  7. #7
    Join Date
    May 2007


    i'm connecting through ADO...
    i asked some1 and he answered me:
    "Put a listbox on the form. Open a recordset on the database, selecting only that field. Populate the listbox with the recordset."

    is it right?
    would u explain me briefly how?

    this is what i write in click event of that button to get data in the list:

    data1.Recordset("property ID")=CInt(list1.list)

    but i get the error: "argument not optional"
    Last edited by kasra100; 05-08-2007 at 04:20 PM.

  8. #8
    Join Date
    Aug 2004
    Orange, California
    No that is not correct. You open a recordset object, call it Rs, and then set the listbox's recordsource property.
    'Note: Cnn is a previously opened connection object ADODB.Connection
    Dim Rs as New ADODB.Recordset
    Rs.Open "SELECT * FROM MyTable;", Cnn, adOpenDynamic, adLockOptimistic
    Set DataList.RecordSource = Rs
    Last edited by Ron Weller; 05-09-2007 at 11:52 AM.

  9. #9
    Join Date
    May 2007

    another browsing problem

    see, i'm tring to implement what u hav said...but i get this error:

    "user-defined type not defined"...

    help me out plz...after that.assume that i got the data rows on the list...now i want the data to appear in the textboxes...
    Last edited by kasra100; 05-09-2007 at 07:47 PM.

  10. #10
    Join Date
    Aug 2004
    Orange, California
    Ok one thing I noticed is that I gave you the wrong property for setting the recordset object. It should be RowSource not RecordSource. Also you will need to set a few properties on the DataList control. First is ListField this should be the name of the field in your recordset that you wish to display in the list. Next is the BoundColumn this needs to be the name of the field in your recordset that contains the PrimaryKey value. Example:
    Option Explicit
    Dim Rs As New ADODB.Recordset
    Dim Sql As String
    Private Sub Form_Load()
      'need code to open connection object here
      Sql = "SELECT * FROM SalesPeople;"
      rs.Open Sql, Cnn, adOpenDynamic, adLockOptimistic
      DataList.BoundColumn = "SalesPersonID"
      DataList.ListField = "SalesPersonName"
      Set DataList.RowSource = rs
    End Sub
    Private Sub DataList_Click()
      MsgBox "Clicked on " & Me.DataList.BoundText & " - " & Me.DataList.Text, , "Click"
      'make sure to start search from the beginning
      rs.Find "SalesPersonID = " & Me.DataList.BoundText
      'if not EOF then record was found
      If Not rs.EOF Then
        'set forms text boxes to recordset values
        Me.txtName = rs("SalesPersonName")
        Me.txtPhone = rs("SalesPersonPhone")
        Me.txtCell = rs("SalesPersonCellPhone")
      End If
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
      On Error Resume Next
      'free up resources   
      Set rs = Nothing
      'need code to close and set connection object to nothing  here
    End Sub

  11. #11
    Join Date
    May 2007
    i know it sounds very simple, BUT i'm vry new to VB (my profession is graphic)...c, how can i open the connection object???...i tried with:
    Dim DBconnectionSF As ADODB.Connection
    Private Sub Form_Load()
    DBconnectionSF.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
          & "Data Source=" & App.Path & "\TS99_v101.mdb;Jet _
          OLEDB:Database Password=work"
    and closed with
    DBconnectionSF.Close: Set DBconnectionSF = nothing
    is it right???...i use the Data connection(Data1) on the toolbox...

  12. #12
    Join Date
    Aug 2004
    Orange, California
    Not quite but very close. You defined DBconnectionSF as a data type of ADODB.Connection; but then you tried to use the object before you created it. You can do this two ways, first is within the Dim statement itself or on a seperate line of code. Ex:
    'On a seperate line od code
    Dim Cnn As ADODB.Connection
    Set Cnn = New ADODB.Connection
    Cnn.Open ......


    'As Part of Dim Statement
    Dim Cnn As New ADODB.Connection
    Cnn.Open .....

    Once you open a connection to the database you can use this connection object anywhere you need a connection. So what I do is open my connection when my program starts up and keep it open until the program ends. This way the connection object is available throughout my application.
    Your connection close followed by setting the variable to nothing is the correct procedure for closing down your connection when you use your own connection variable. Which is basically what you did when you used the Dim statement. There is no reason to use the datacontrol from the toolbox. You can use the datacontrol if you want but most programmers like to have more control and don't like the overhead of using the data control. Plus it makes your forms look messy!

    The datacontrol incorporates the connection object, recordset object, and the buttons needed to move froward and backword through the records in the recordset. It also allows you to bind controls the the datacontrol for editing. A lot of programmers would rather use their own objects and their own buttons to control the recordset movements. We like the control we get when we use our own objects. It does require more coding though.
    Last edited by Ron Weller; 05-10-2007 at 11:41 AM.

  13. #13
    Join Date
    May 2007
    Kiri ye solam bokon bebein chetor mishe ba prompt search kard koniya kasi be man javab nemide

  14. #14
    Join Date
    May 2007
    i'm back again...
    guys i have 3 problems(i use data control):
    1.what should i do to highlight the data inside the textbox? for example, in rent text box, 0 is always there...i use:
    txt_rent.SelStart = 0
    txt_rent.SelLength = Len(txt_rent.Text)
    it highlight the textbox...but u can't enter more than one number

    second>when u press next, it goes and goes till it reaches to the end offile and then the msgbox with debug appears...how can i stop and inform the user that here is the last record(with a msgbox)???

    Third>i have a search prompt..but it doesn't work...i use:
    prompt$ = "Enter the full (complete)supplier title."
    'get string to be used in the SupplierName field search
    SearchStr$ = InputBox(prompt$, "Supplier search")
    datsupplier.Recordset.Index = "SupplierName"    'use SupplierName
    datsupplier.Recordset.Seek "=", SearchStr$   'and search
    If datsupplier.Recordset.NoMatch Then        'if no match
    datsupplier.Recordset.MoveFirst              'go to first record
    End If
    but it doesn't work
    tnx in advance

  15. #15
    Join Date
    May 2007
    Hi, this post is very informative; however I would like some specific information. If someone can help me then please send me a private message. Best Regards,

Similar Threads

  1. Told you so.... C# replacing VB
    By Bob in forum .NET
    Replies: 44
    Last Post: 06-06-2008, 04:39 AM
  2. re: moving from VB to C# -- more reasons
    By Jeff Johnson in forum .NET
    Replies: 6
    Last Post: 01-18-2007, 07:44 AM
  3. VB Code with excel.....Plz HELP!
    By test1986 in forum VB Classic
    Replies: 0
    Last Post: 10-27-2006, 06:38 AM
  4. VB with Excel - Plz Help
    By prismmb in forum VB Classic
    Replies: 2
    Last Post: 10-12-2006, 04:32 PM
  5. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 12:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.