add data to another database using ADODB

What's wrong with this code? Howcome still got error?


Code
________________________________________________

Dim SQL As String
SQL = "Update Table1 ([Password],[Level])" & _
" IN 'G:\Documents and Settings\IA_TRAINING01\My Documents\odbc.mdb'" & _
" Set password = '" & Me.Text5 & "' " & _
" Where password = '" & Me.Text1 & "' And " & _
"level = '" & Me.Text3 & "'"

CurrentProject.Connection.Execute SQL <----------Error encounted

_________________________________________________
 
Last edited:
Wayne,
If you saw this msg please tell me whats wrong is my code?
 
And also how example the 1st record is Admin that what command when u click on the delete button it'll not delete the admin record only other record can be deleted
 
dream,

Here are your forms. The form will take a passwork and level.
If it exists in the other database, it will update it, otherwise
it will insert it.

Wayne
 
So where do i insert the code in? Or do i need to add a command button to put the code in it?
 
wayne,

when i key in the user name same as the table and another password for it bt it add a new record to it but it did not overwrite the default 1

I know already what u do is edit the level instead of password so i need to do some changing in the code right?

But what if i only 1 the password and the level cannot add the same 1 if theres a record in the table
 
Last edited:
dream,

The table only has a password and a level. If you want to
bring username into it, add it to the table, add it to the
form, and add it to the code.

Wayne
 
Wayne,

nonono ya my table only go password and level but i wanna know is how to make sure that the table does not have the same password and level?

where do i add the msgbox to let the user know that the pass or level in use...


code:
_________________________________________________
Private Sub Command0_Click()
Dim SQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb

SQL = "Select * " & _
"From Table1 in 'G:\Documents and Settings\IA_TRAINING01\My Documents\db1.mdb' " & _
"Where Level = '" & Me.Text3 & "'"
Set rst = dbs.OpenRecordset(SQL)
If rst.EOF And rst.BOF Then
SQL = "Select * " & _
"From Table1 in 'G:\Documents and Settings\IA_TRAINING01\My Documents\db1.mdb'"
Set rst = dbs.OpenRecordset(SQL)
rst.AddNew
rst!Password = Me.Text1
rst!Level = Me.Text3
rst.Update
Else
SQL = "Select * " & _
"From Table1 in 'G:\Documents and Settings\IA_TRAINING01\My Documents\db1.mdb' " & _
"Where Level = '" & Me.Text3 & "'"
Set rst = dbs.OpenRecordset(SQL)
rst.Edit
rst!Password = Me.Text1
rst!Level = Me.Text3
rst.Update
End If
End Sub
___________________________________________________
 
Last edited:
Sorrie... don't wanna waste time posting new topic just recycle..

ok heres my problem.

I got a table in another database and in it got 3 fields (username, password, level).

i've make a form in it got 3 textboxes and 1 command button.

What i want is the textboxes can show the records of those who have register and the level is left blank. The only person to gave the level is the administrator so i created a button for the admin to edit the level. But how should i create a password on the command button to identify that the person that click on the button is admin?
 
dream,

When the user clicks on the command button, you can bring
up a dialog box that asks for the password. You can use
the "password" font so that it will echo "*" when they
type. If they type in the right password, bring up the
form to edit the data.

Wayne
 
ok but how do can i use the nav button to see all the registered user in the textboxes from another database?
 
dream,

But how should i create a password on the command button to
identify that the person that click on the button is admin?

That's what my last post did.

If you want to see all of the users in the table in the
other database, you will have to use a listbox or combo
box.

It's rowsource can be like in one of our earlier posts:
Select ... From ... In ...Where ...

Wayne
 
dream,

If you mean can you have a label with a scroll bar, I don't
think so. Why would you want it? Text fields (like memos)
can have them.

Wayne
 
Wayne,

No, I mean like a anitmation that can silde from right to left.... :-)
 

Users who are viewing this thread

Back
Top Bottom