473,406 Members | 2,816 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,406 software developers and data experts.

Autoupdate all records in a table using VBA and SQL

3
Hello everyone,

I have been looking on the net to solve my problem for several days now, but i couldn't find what I was looking for.

I'm designing a database for a university and in one of the forms I have a text field called "Thesis Plan Due Date". User will enter the due date for submission of student's thesis in this text field.

What i want to do is that when the user has specified the due date for the first student, I want the vba code to copy that due date to the "Thesis Plan Due Date" fields of all the student in the "Thesis Applicant Information" table. I know that this code should go in the AfterUpdate event of my text field, but I'm not sure how it should be written.

I made the following SQL statemtn but I'm not sure if it's suppose to do what I want :D
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim date As Variant
  3. date = Me.[Thesis Plan Due Date].value
  4. CurrentDb.Execute ("INSERT INTO [Thesis Applicant Information]( [Thesis Plan Due Date])" _
  5.  & "SELECT " & date ";")
  6.  
What i found on the net was how to copy the fields in one table to another table but how should I write the VBA or SQL statement do what I want.


Thanks in advance for your time.

P.S. I recently found this site and this is my first post :D
Jun 5 '07 #1
4 2289
Parsa
3
I have come up with this code so far, can anyone tell me why it is not working?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbo_ThesisPlanDueDate_AfterUpdate()
  2.     Dim strDueDate As String
  3.    'I use vbNullstring just in case there isn't anything in the textbox.
  4.     strDueDate = Me.[Thesis Plan Due Date].Value & vbNullString
  5.     If IsDate(strDueDate) = True Then
  6.  
  7.         Dim rst As DAO.Recordset
  8.  
  9.         Set rst = CurrentDb![Thesis Applicant Information].OpenRecordset
  10.  
  11.         Do While Not rst.EOF
  12.         CurrentDb.Execute Query:="INSERT INTO [Thesis Applicant Information] ([Thesis Plan Due Date]) VALUES ('" & strDueDate & "')"
  13.           rst.MoveNext
  14.         Loop
  15.  
  16.  
  17.     End If
  18. End Sub
Jun 5 '07 #2
Rabbit
12,516 Expert Mod 8TB
An INSERT INTO query adds records, you're probably looking for an UPDATE query.

Also, if it is a date, you shouldn't store it as a text. It screws up sorting, filtering, and calculations that you can perform on a date.
Jun 5 '07 #3
Parsa
3
Thanks Rabbit,

I changed it to UPDATE and it's fine now... thanks :d
Jun 5 '07 #4
Rabbit
12,516 Expert Mod 8TB
Not a problem. Good Luck.
Jun 5 '07 #5

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

Similar topics

0
by: noam_a_jacobs | last post by:
Hi, I have a technical question for those smart cookies with update management experience. We use a product called EasyUpdate, from www.AutoUpdatePlus.com, to manage the updates of our app after...
0
by: Cute^_^ | last post by:
Hi all, Just recently started to learn how to use Access2002 and discovered the power of programming a database. Lately, I want to create a database for my own use. There are some quires I would...
4
by: Scott Kinney | last post by:
I have an inventory database. I want to delete out-of-stock items from the main database, but keep them in a separate table so that I can reference data about them. I created a copy of the item...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
12
by: jaYPee | last post by:
I have currently using a dataset to access my data from sql server 2000. The dataset contains 3 tables that is related to each other. parent/child/grandchild relationship. My problem is it's very...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
11
by: kaisersose1995 | last post by:
Hi, I've got an import procedure working, using a standard import specification to import a .csv file into a temporary table. The problem i'm having is that i have 4 different sets of borrower...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
1
by: tasmontique | last post by:
I am using access 2000. I have two questions Question 1 I have 3 tables. tblFlight, tblAircraftType, tblFlightProgramIN/OUT. tblFlight has a 1 to many relationship with tblAircraftType,...
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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.