Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating reccords to be 'filled in'

Status
Not open for further replies.

blurworld

Programmer
Sep 19, 2001
46
GB
hi,

ok i'm trying to automaticly create new records (targets) in a datasheet view, so that (target) values can be entered, with details (customer, month etc) already automaticly in them (from the customer table and a given month) for each customer.
A customer and Account_Target table exists.

hope this makes sense, any ideas? cheers,

-Martin
 
Are you trying to create a new record with a certain amount of existing information?

Zero

Programming evolves from imagination.
 
hi

yes i am, i'm half way there i think, i have done a select query which lists all the customers with a record to enter the target values but i want the date to be entered in each of these records automaticly as well is there anyway to do this in a query?,
i can send a sample of the database if u wish,

-Martin
 
Hint: only use a query as a last resort.. use VB or SQL as much as possible this will limit the no. of problems in the future. I am not saying that it prevents all probs but will save on a lot.

For example if you are pulling information via a query to use on your form and you have linked two tables together to do so and you plan on sending the info gained to one of the two tables you may find it will not add new records.

here is a better way to do it. on the main link field in your form. this is the one that you use to link queries. lets say for this example the field on the form is called customer_no. and the link is custno.

in the before update add the following

Private Sub customer_no_BeforeUpdate(Cancel As Integer)
Dim strFilter As String
strFilter = "custno = " & Me!customer_no
me!Fsurname=DLookup("[Tsurname]","customers", strFilter)
me!Ffirstname=DLookup("[Tfirstname]","customers", strFilter)
me!Fphoneno=DLookup("[Tphoneno]","customers", strFilter)
End Sub



Customer_no = field name in the form
custno = Link in the table
customers = name of the table
F in front of name = Form field name
T in front of name = Table field name

Explanation: one you select the customers no in the customer_no field the form will then look at the table customers and pull all information on the customerno line into the form.


Ok as for the date just add a field to your form and in the default value add:
=Date()

this will automaticly put the date at the time of creation in the field.

Hope this helps.

Zero :)

programming evolves from Imagination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top