Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Access assing records


Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2003, 07:53 AM
Pino's Avatar
Pino Pino is offline
Banned
 
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
Exclamation Access - New Records


hey all, i know how to read data stored in a database heres my code..

Code:
Option Explicit Public sqltxt As String Public mydatabase As Database Public myrecs As Recordset Private Sub Command1_Click() GoForIt Form1.txtusername, Form1.txtpassword End Sub Public Sub GoForIt(userid, pwd) Set mydatabase = Workspaces(0).OpenDatabase("c:\db1.mdb") sqltxt = "select password from tblUsers where Username='" & userid & "'" Set myrecs = mydatabase.OpenRecordset(sqltxt, , dbOpenSnapshot) If Not myrecs.EOF Then If myrecs("password") = pwd Then MsgBox "You are OK!" Else MsgBox "Illegal Password!" End If Else MsgBox "Illegal UserID" End If myrecs.Close Set myrecs = Nothing Set mydatabase = Nothing End Sub
all works fine but now i'm creating a new user form so i will need to add data to the database, anyone got any ideas on how to do this?

PINO

Last edited by Pino; 11-08-2003 at 08:43 AM.
Reply With Quote
  #2  
Old 11-08-2003, 09:35 AM
Pino's Avatar
Pino Pino is offline
Banned
 
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
Default

I know this part of the code

Code:
dbOpenSnapshot

makes it so its READ ONLY but i dont know what the other commands are to make it not read only

anyone help MUCH appriciated

PINO
Reply With Quote
  #3  
Old 11-08-2003, 11:40 AM
Shurik12 Shurik12 is offline
Steppe Walker

Retired Moderator
* Expert *
 
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
Default

Hi,

Have a look at the Execute method of the database object and "Insert Into.. " sql statement:

mydatabase.Execute "Insert Into ...."


Regards,

Shurik.
Reply With Quote
  #4  
Old 11-08-2003, 12:21 PM
Pino's Avatar
Pino Pino is offline
Banned
 
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
Default

Code:
myrecs.Edit myrecs("Username") = txtusername.Text myrecs("Password") = txtpassword.Text myrecs("message1") = txtmsg1.Text myrecs("message2") = txtmsg2.Text myrecs("message3") = txtmsg3.Text myrecs("message4") = txtmsg4.Text myrecs("message5") = txtmsg5.Text myrecs.Update

dun
Reply With Quote
  #5  
Old 11-09-2003, 02:40 AM
Pino's Avatar
Pino Pino is offline
Banned
 
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
Default

sorry i added my edit code rather than my add new sub :-p

Code:
myrecs.AddNew myrecs("Username") = InputBox("Username?", "User Admin") myrecs("Password") = InputBox("Password?", "User Admin") myrecs("message1") = "(none)" myrecs("message2") = "(none)" myrecs("message3") = "(none)" myrecs("message4") = "(none)" myrecs("message5") = "(none)" myrecs.Update
Reply With Quote
  #6  
Old 11-09-2003, 09:51 AM
SteadVex SteadVex is offline
Freshman
 
Join Date: Oct 2003
Location: UK
Posts: 28
Default

Hi, i'm looking to access a database from excel via code i want to be able to load up records into variables, from what i've been able to figure out its you need a new sheet with a pivot table,

I was wondering if you could or someone else could explain how the code works shown in this thread
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How many records support Access 2000 and Access 97? geo1st487 Database and Reporting 1 03-15-2003 03:21 PM
VB Access integration records??? nfear24 Word, PowerPoint, Outlook, and Other Office Products 4 01-30-2003 12:36 PM
entering new records in access tbl always come to front of table? Wildbeliefs Database and Reporting 19 12-22-2002 10:48 AM
Using ADO with Access to create Word report, getting duplicate records Timkoma Word, PowerPoint, Outlook, and Other Office Products 5 02-27-2002 01:28 PM
Add new records from a delimited txt file Access.. Ricko General 12 04-03-2001 07:37 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->