Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
using a text box to add or edit information
View previous topic :: View next topic  
Author Message
SKP
Newbie


Joined: 23 Dec 2003
Posts: 7

PostPosted: Jan 7th, 2004 11:32 AM    Post subject: using a text box to add or edit information Reply with quote

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
View user's profile Send private message
VBMaster
Newbie


Joined: 02 Feb 2004
Posts: 5

PostPosted: Feb 3rd, 2004 11:56 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 4th, 2004 02:58 PM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic