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 08:13 PM.
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...
This should get you started
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
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"
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)...
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.
I Got Stuck Again...
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????????
TNX IN ADVANCE
How are you connecting to your database?
ADO Code (hopefully)
ADODC bound data control
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
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:
but i get the error: "argument not optional"
Last edited by kasra100; 05-08-2007 at 05:20 PM.
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 12:52 PM.
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 08:47 PM.
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:
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
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")
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
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:
and closed 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 _
is it right???...i use the Data connection(Data1) on the toolbox...
DBconnectionSF.Close: Set DBconnectionSF = nothing
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
'As Part of Dim Statement
Dim Cnn As New ADODB.Connection
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 12:41 PM.
Kiri ye solam bokon bebein chetor mishe ba prompt search kard koniya kasi be man javab nemide
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:
it highlight the textbox...but u can't enter more than one number
txt_rent.SelStart = 0
txt_rent.SelLength = Len(txt_rent.Text)
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:
but it doesn't work
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
tnx in advance
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,
Last Post: 06-06-2008, 05:39 AM
By Jeff Johnson in forum .NET
Last Post: 01-18-2007, 08:44 AM
By test1986 in forum VB Classic
Last Post: 10-27-2006, 07:38 AM
By prismmb in forum VB Classic
Last Post: 10-12-2006, 05:32 PM
By Glen Kunene in forum Talk to the Editors
Last Post: 03-23-2002, 01:43 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL