Automatically Add Record to table

P

ParrotGirl

Hello,
I have created a weekly service database, and I am trying to automatically
add a record to a table.
Main Table: JobID -
Service End - Job is no longer on service.

Service Table - Links to JobID
ServiceID
Date
Completed y/n

I want my technician to open a form that shows all service items that are
not completed. as they update what has been completed and that service end
is null, i would like a button that they press to add a new service record
and auto fill in service date (adding 1 week)
doing this manually is time consuming as we may have 100 or more services at
one time
thanks for any help
Chris
 
J

Jackie L

It sould like you just need to add a button to go to a new record with code
like the following:

DoCmd.GoToRecord , , acNewRec
Me.ServiceDate = DateAdd("d", 7, Date)

Hope this helps.
Jackie
 
P

ParrotGirl

I will try this, the button I understand and the date add also, just not
clear on adding 100 records, were the criteria is completed yes and service
end is null.
chris
 
P

ParrotGirl

This is what I have so far, It works on one record at a time only.

Private Sub CmdAddPoolCare_Click()

DoCmd.GoToRecord , , acNewRec
If Me.NewRecord Then
Me.ServDate = DMax("ServDate", "SERVICE TABLE") + 7

End If

End Sub

I need to add this to the code

If Me.Completed = False (pool care was not completed) (AND/OR)
If Me.[Job Table]. PoolCareDay = is not null (no longer on pool service)
Then do nothing (do not add record)

If Me.[SERVICE TABLE].[Completed] = True and If Me.[Job Table]. PoolCareDay
= is null then add record

Also, how about a msg box that 1. Confirms that you want to add records, and
2. Gives you an account of how many you are changing.

As I Said before, my tech updates at least 100 jobs per week. So is there
some place that I need to link JOB TABLE.JOBID TO SERVICE TABLE.JOBID when
it add’s new records?
 
J

Jackie L

Since I am not sure on your data structure, you could use an Append Query if
you have the 100 services in a table, then have the date field added in the
query with the same expression as mentioned earlier. Attach the running of
the Append query to a button like:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendQueryName"
DoCmd.SetWarnings True
Me.Requery

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top