| View previous topic :: View next topic |
| Author |
Message |
SKP Newbie
Joined: 23 Dec 2003 Posts: 7
|
Posted: Jan 7th, 2004 11:32 AM Post subject: using a text box to add or edit information |
|
|
I have a form that I want to be able to use one text box to add a new record (if the project number is not already there) or to edit an existing record if the number has been used. The project number is my primary key. I'm having trouble trying to figure out the best way to attack this. I've tried getting the text from the box and setting focus back to the text box and then calling the FindRecord command but I end up getting errors. Any ideas??
Thanks in advance! |
|
| Back to top |
|
VBMaster Newbie
Joined: 02 Feb 2004 Posts: 5
|
Posted: Feb 3rd, 2004 11:56 AM Post subject: |
|
|
No sorry no ideas, Maybe if you explained what you are doing a little more then maybe I can help. _________________ VB is like teaching a computer to do things...why can't it be that simple for humans.
Richard |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 4th, 2004 02:58 PM Post subject: |
|
|
This can be accomplished in a few steps using SWL and ADO. I try not to bind textboxes on "formal" projects I work on. If I need to use it for some difficult database manipulation, I use ADO...a quick way to setup ADO is as follows:
| Code: |
Private DB As ADODB.Connection
Private RS1 As ADODB.Recordset
Private Sub Form_Load()
'Requires "Microsoft ActiveX Data Objects" (Any version, prefer 2.5+)
'Menu: Project | References
Set DB = New ADODB.Connection
Set RS1 = New ADODB.Recordset
'RS1 is a recordset object.
'This can be information pulled from a SQL SELECT statement
ConnectString = "DSN=TestData"
' ** To make a DSN in Windows 2k/XP
' Open the Control Panel, under Admin Tools
' Select Data Sources (ODBC)
' Hit add and walk through the Wizard.
' You can make FileDSN's which you can distribute with
' the program, but I'm not getting into that in this example.
'Connect to the Database
DB.Open ConnectString
'This will select a set of records from Table1
'and put it in RS1
RS1.Open "SELECT * FROM Table1;", DB
'If there is a FirstName Field in the database,
'you reference it with the !
Debug.Print RS1!FirstName
'This will delete all the records in Table1
DB.Execute "DELETE * FROM Table1;"
End Sub
|
It may look a little confusing at first, but check it out. It's worth the time to learn it. _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
|