[RESOLVED] 3 problems...Can anyone help me?
Hi!
My first problem is about a command button for browsing an image.
I don't know how to make a command button that when you click the button, it will just browse.
I made an Student ID form with an image using a data control. During runtime, I can't browse the image because I want to select an image for the student.:eek2:
If you still can't get what I mean, try clicking on the databasename on the properties window. The command button for browsing is what I'm asking for the code. :confused:
The second problem is comparing the database names. Since I've created a Student ID form, of course I'll input their first names, middle names and last names. But what if the first name and last name was inputted twice? How do you prevent this? What is the code for searching the database for any duplicate names?
My last problem is the Auto-Numbering of the student ID.
Many thanks! :bigyello:
Re: 3 problems...Can anyone help me?
go to components and click microsoft forms 2.0 object library and use a button from there for the first problem
Re: 3 problems...Can anyone help me?
Quote:
Originally Posted by louvelle
My first problem is about a command button for browsing an image.
I don't know how to make a command button that when you click the button, it will just browse.
Go to Components (ctrl+T) and add Microsoft Common Dialog control.
Then add Picturebox and command button, copy/paste and run sample code below:
Code:
Private Sub Command1_Click()
With CommonDialog1
.FileName = ""
.InitDir = "c:\"
.Filter = "All Pictures (*.bmp;*.jpg;*.gif;*.ico)|*.bmp;*.jpg;*.gif;*.ico"
.ShowOpen
If Not .FileName = "" Then
Set Picture1.Picture = LoadPicture(.FileName)
End If
End With
End Sub
Re: 3 problems...Can anyone help me?
I don't have a visualbasic at home but if I use the code, will it browse and place the image that I selected to the Image box?
Sorry, just a new at vb6...
Re: 3 problems...Can anyone help me?
That is precisely what the code does.
Re: 3 problems...Can anyone help me?
Ahh.. I see.. Got any ideas on my second problem?
Re: 3 problems...Can anyone help me?
Your 2nd and 3rd question are database related - I suggest you read some topics in our DB FAQ forum first.
Also, you need to specify what type of database you use.
Re: 3 problems...Can anyone help me?
I'm just using the data control...
Re: 3 problems...Can anyone help me?
Data control is something that helps you connect to your database and also manipulate your data.
However, you must have DATABASE first - MS Access, MS SQL, Oracle, MySql, etc, etc, etc...
Since you are completely new to working with databases I recommend you visit our Databse FAQ forum first.
Without educating yourself on the the topic you won't get anywhere further than where you are now.
Good luck.
Re: 3 problems...Can anyone help me?
I've found my answer to my 3rd problem. Thanks.
But I couldn't find anything about my 2nd problem..
I'm using MS Access for my database...
Re: 3 problems...Can anyone help me?
I believe, you are having a form for entering student details ("StudentID form"). And it contains two text boxes named txtName and txtLastName, for entering first name and last name respectively. And a command button named cmdSave for saving the data into the database. Then you can use the following code for checking the the last name and first name..
Code:
Private Sub cmdSave_Click()
If Trim(LCase(txtFirstName.Text)) = Trim(LCase(txtLastName.Text)) Then
MsgBox "Both last name and first name are same..! Please change it..!", vbCritical, "Same..!"
txtLastName.SetFocus
Exit Sub
Else
'code for saving the data into the database
End If
End Sub
Please keep in mind that, this code is for checking duplicates when you are adding a new data using the StudentID form and it will not check for any duplicates that has been already entered in the database..... :)
Re: 3 problems...Can anyone help me?
It's ok. I'll just input a code so that the data won't save... Thank you guys!