 |
 |

11-08-2003, 07:53 AM
|
 |
Banned
|
|
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
|
|
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.
|

11-08-2003, 09:35 AM
|
 |
Banned
|
|
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
|
|
I know this part of the code
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
|
|

11-08-2003, 11:40 AM
|
|
Steppe Walker
Retired Moderator * Expert *
|
|
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
|
|
|
Hi,
Have a look at the Execute method of the database object and "Insert Into.. " sql statement:
mydatabase.Execute "Insert Into ...."
Regards,
Shurik.
|
|

11-08-2003, 12:21 PM
|
 |
Banned
|
|
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
|
|
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 
|
|

11-09-2003, 02:40 AM
|
 |
Banned
|
|
Join Date: Sep 2003
Location: Manchester, U.K!
Posts: 169
|
|
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
|
|

11-09-2003, 09:51 AM
|
|
Freshman
|
|
Join Date: Oct 2003
Location: UK
Posts: 28
|
|
|
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
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|