Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2005, 03:02 PM
Authorized User
 
Join Date: Feb 2004
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert into problem

Hello every one
i have two tables
Table 1:
recid autonumber
userid text
Table 2:
recid number
userid text
now how can i add the recid and userid in table number two
(by the way relations has been set and this is the command i am using)
DoCmd.RunSQL "insert into attempts(recid,lastsignon,un,mn) values('" & Me.recid.Value ','"&now()&"','"&un()&"','"&mn()&"')"
but i am getting erro revery time i try to run it
the reason is instead of every time sending the login data in to the same table i want to send in to seperate table it is easier this way to keep track of every one
here is my code
http://www.hgh.demon.co.uk/test.zip
Best Regards,
Hamed Gholamian
 
Old February 25th, 2005, 08:11 AM
Authorized User
 
Join Date: Feb 2004
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry again i manage to fix it but here is the code
Dim intUserID
intUserID = DLookup("recId", "tblUserSecurity_Sec", "[UserID]='" & Me.txtUserID & "'")
DoCmd.RunSQL "INSERT INTO attempts ( lastsignon,userid) SELECT Now() AS lastLogin, " & intUserID

it goest after the cmd login at the last line before i close it but how can i add two more values in to this table the first one is un and the other one is mn and un and mn both of them are function and also same as field name
PS: i just upload the new updates in to link that i provided inmy previous message
Best Regards,
Hamed Gholamian
 
Old February 25th, 2005, 02:01 PM
Authorized User
 
Join Date: Feb 2004
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

any one please please please i need help

Best Regards,
Hamed Gholamian
 
Old March 3rd, 2005, 05:16 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Hamed,

I think you are almost there! Have a look below and let me know if this helps.

Code Starts - - -
Dim lngUserID As Long
Dim strSQL As String

lngUserID = DLookup("recID", "tbl_UserSecuritySec", "[UserID]='" & txtUserID & "'")

If lngUserID = 0 Then Exit Sub 'Exit if not match?

strSQL = "INSERT INTO tbl_Attempts ( LastSignon, UserID, mn, un ) " & _
        "SELECT Now() AS CurTime, " & lngUserID & " AS CurUserID, mn() AS Funct1, un() AS Funct2; "

DoCmd.RunSQL strSQL

Code Ends - - -

This does exactly what you did but now has the addition of two functions which are appended to the table. The functions are held in a module and are public. Is this correct?

Jon





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert problem lscjtw XSLT 2 August 3rd, 2007 10:29 AM
Validation and Insert problem addos Beginning PHP 0 January 17th, 2005 06:50 PM
problem with insert iosqar JSP Basics 0 May 19th, 2004 10:07 AM
Insert problem CW Classic ASP Databases 14 September 9th, 2003 04:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.