473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Variable already exist error (MS Access)

I am trying to load data from two separate tables into a third table. Log the load time into another table. However anytime i run my scripts in Access, the data doesnt load and i get variable exist error. I need help.

Below is my code:
Dim dbs As Database
Dim qdf As QueryDef
Dim sql As String
Dim mytimer As Date
Dim rcvd_date As Date
Dim mydate As Date
Dim icount As Integer
Dim load_index As Integer


Set dbs = CurrentDb
'dbs.Execute "drop mydate;"
dbs.Execute "SELECT Max(loadDate) into mydate FROM load_scheduler;"

'10/7/1999 4:45:00 PM
If DateValue(mydate) = #10/7/1999# Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts;"
icount = dbs.RecordsAffected
dbs.Execute "select max([date received]) into rcvd_date from contacts;"
dbs.Execute "insert into load_scheduler values(rcvd_date, now(), 1);"

ElseIf DateValue(mydate) > #10/7/1999# Then
dbs.Execute "select max([date received]) into rcvd_date from contacts;"
If rcvd_date > mydate Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts where [Date Received] >= mydate;"
dbs.Execute "INSERT into load_scheduler values(rcvd_date, now(), 1);"
ElseIf rcvd_date < mydate Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts where [Date Received] <= mydate;"
dbs.Execute "INSERT into load_scheduler values(rcvd_date, now(), 1);"
ElseIf rcvd_date = mydate Then
End

End If
End If



End Sub
Jan 31 '08 #1
1 1827
ADezii
8,834 Expert 8TB
I am trying to load data from two separate tables into a third table. Log the load time into another table. However anytime i run my scripts in Access, the data doesnt load and i get variable exist error. I need help.

Below is my code:
Dim dbs As Database
Dim qdf As QueryDef
Dim sql As String
Dim mytimer As Date
Dim rcvd_date As Date
Dim mydate As Date
Dim icount As Integer
Dim load_index As Integer


Set dbs = CurrentDb
'dbs.Execute "drop mydate;"
dbs.Execute "SELECT Max(loadDate) into mydate FROM load_scheduler;"

'10/7/1999 4:45:00 PM
If DateValue(mydate) = #10/7/1999# Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts;"
icount = dbs.RecordsAffected
dbs.Execute "select max([date received]) into rcvd_date from contacts;"
dbs.Execute "insert into load_scheduler values(rcvd_date, now(), 1);"

ElseIf DateValue(mydate) > #10/7/1999# Then
dbs.Execute "select max([date received]) into rcvd_date from contacts;"
If rcvd_date > mydate Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts where [Date Received] >= mydate;"
dbs.Execute "INSERT into load_scheduler values(rcvd_date, now(), 1);"
ElseIf rcvd_date < mydate Then
dbs.Execute "INSERT INTO comptrackdata ( [Date Received From Customer], [Customer Company/Department], [External Customer], [Customer Contact], [Contact phone], ContactEmail, Complaint, [Specific Product/Service], Investigation, [First response to customer by receiver of comment], [Date Completed or moved to CAPA] )SELECT [Date Received], companyname, 1, [customer name], workphone, emailname, Question, catalognumber, Response, Notes, [date closed]FROM Contacts where [Date Received] <= mydate;"
dbs.Execute "INSERT into load_scheduler values(rcvd_date, now(), 1);"
ElseIf rcvd_date = mydate Then
End

End If
End If



End Sub
It appears to me that mydate refers to both a Variable and a Table which makes things a little ambiguous. Change the Name of the Variable to something different.
Expand|Select|Wrap|Line Numbers
  1. Dim mydate As Date
  2. dbs.Execute "SELECT Max(loadDate) into mydate FROM load_scheduler;"
Jan 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matthew Louden | last post by:
I attempt to connect ASP.NET application with SQL Server using ADO.NET. I just open a connection, and it had run-time error in line 34: cn.open(): SQL Server does not exist or access denied....
9
by: Steven Ung | last post by:
Hello all, I'm having the following error dump from an ASP.net application. The program is to calculate MRP and it involves complex queries looping thru hundreds of records in an few SQL 2000...
6
by: kwdavids | last post by:
I'm getting occasional instances of the error: SQL Server does not exist or access denied I get the error both in application code and from Enterprise Manager. The database is LOCAL. ...
3
by: sammyloo | last post by:
Hi all, I'm experiencing a problem using ASP.NET web services to access a different server with SQL Server 2000 database. And I get the error of the following Exception Details:...
1
by: Atia Amin | last post by:
Hi, I am a new member. Hello to every one. I am new in ASP.NET area. I wrote an ASP.NET web application which was running ok with my old laptop. Currently I have given a new laptop. Now I copied...
1
by: vamshika | last post by:
hi, I got a serious Problem. I get "Server does not exist or access denied" with 80004005 as the error code. the win2003 server uses all the latest components(like iis6,jet..etc) and is upto date....
3
by: byeung | last post by:
Hi, I am trying to check if a particular record already exists in an Access database through Excel vba code. Through code obtained at another forum, I got the following: ...
2
by: =?Utf-8?B?SDIw?= | last post by:
I'm having a problem with the access control in windows server 2003. I have set in our server that user can access, modify, read and write folders/files but not able to delete folders, subfolders...
31
by: ladybanks | last post by:
Hello Everyone, I am developing a software to load data from 2 separate tables. Each time data is loaded, i want to log the max (date/time) of each table into a scheduler table (third table). I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.