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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datasheet Input Form 2

Status
Not open for further replies.

SimonPGreen

IS-IT--Management
Mar 8, 2004
116
GB
Hi,

I've had a good play with DoCmd.Openform but can't work out if it possible to achieve my goal. I have a main form bound to a table on the one side and a datasheet form bound to a query selecting records from both the table bound to the main form and a related table.

The datasheet view form is opened via command button from the main form using DoCmd.Openform. At present this is opensin Edit so that all records matching the where condition are displayed - the where is defined using a control value from the main form - no problem. I want a user to be able to add additional rows to the datasheet view without having to manually enter the foreign key value or lookup manually i.e.

[ValNo] [Date] [Value] [FKRef]
1 10/1/07 100 26 <- existing record
2 10/2/07 300 <- New Record

The key thing here is that the user needs to be able to see all of the records returned by the query for reference whilst being able to add new records in a datsheet.

Is this possible?

Regards,

Simon
 
How does the query work? Does it only return records with the same foreign key?
 
Have a look at OpenArgs

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV.

I've had a look at openargs now and understand that I can pass a value from the calling form and use this on a form event.

What I can't work out is what event could I trap on a datasheet form to capture the adding of a new record - if I can do that I can force the new record to the correct package using the openargs value (I think!)

I can obviously use the form open event to do the first record if it doesn't exist but after that I'm a bi stuck.

Regards,

Simon
 
Thanks,

Resolved by using the newrecord property and openargs:

Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    If Me.NewRecord Then
    Me!FKPackageRef = Me.OpenArgs
    End If
End Sub

Not sure if it's the best event to choose but that will come with time!

Appreciate the help

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top