ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   creating a database and database query (https://www.excelbanter.com/excel-programming/293409-creating-database-database-query.html)

tim

creating a database and database query
 
I have created a form which contains persons details, along
with other information.
I would like to store the person's details into a database.
I would also like to be able to set the form up to query
the database everytime the person's surname is entered, to
see if the person is already in the database. I would then
like to import the person details back in, if they are
already in the database(save typing it all out again).
Is this possible in Excel. (I know this is more of an
Access type function, but I have even less knowledge of
Access.)
I have tried searching other sites but can't seem to find
anything that will walk me through this.

Thanks
..

Dick Kusleika[_3_]

creating a database and database query
 
Tim

You can certainly do this. Make sure your sheet with the data is set up
like a database, i.e. fields and records. Then, I presume, you will have a
textbox on the form in which the user will type the surname. You can FIND
the surname on the sheet and populate other controls on the form with the
information. Here's the basic construct.

Dim FndRng as Range

Set FndRng =
Sheets("Data").UsedRange.Columns(1).Find(Me.TextBo x1.Text,,xlWhole)

If Not FndRng Is Nothing Then
'Surname found
Me.TextBox2.Text = FndRng.Offset(0,1).Value
Me.TextBox3.Text = FndRng.Offset(0,2).Value
'etc.
End If

Then, to write back to the database, do the same thing, with a provision for
new records.

'same Dim and Set as above

If FndRng Is Nothing Then
'Surname not found so new record
Set FndRng = Sheets("Data").Range("A65536").End(xlUp).Offset(1, 0)
End If

FndRng.Offset(0,1).Value = Me.TextBox2.Text
'etc...

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Tim" wrote in message
...
I have created a form which contains persons details, along
with other information.
I would like to store the person's details into a database.
I would also like to be able to set the form up to query
the database everytime the person's surname is entered, to
see if the person is already in the database. I would then
like to import the person details back in, if they are
already in the database(save typing it all out again).
Is this possible in Excel. (I know this is more of an
Access type function, but I have even less knowledge of
Access.)
I have tried searching other sites but can't seem to find
anything that will walk me through this.

Thanks
.





All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com