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!

How can I automate this?? 1

Status
Not open for further replies.

jasonmac

Programmer
Nov 14, 2002
175
US
Hello all. I have a form in access '97 that opens another form in datasheet view. These forms are related by a field called "RecordNo". This is the code I use:

Code:
Private Sub cmdInvoices_Click()
Dim stcrit As String

 stcrit = "RecordNo = " & Me!txtRecordNo.Value
        Debug.Print stcrit

        
        
DoCmd.OpenForm "sbfrmInvoiceER", acFormDS, , stcrit
Forms![sbfrmInvoiceER]![txtRecordNo] = Me.txtRecordNo
Forms![sbfrmInvoiceER].Caption = "Record " & Me.txtRecordNo & " Invioces"
        
End Sub

This works fine when the form is first opened but when more than one record is to be added the record number defaults to 0 or is left as Null. I don't want the user to have to manually enter the RecordNo for each invoice number he adds to the datasheet. How can I automate this?

Thanks in advance,
Jason
 
I think rather than pushing the info from the calling form (which would then be only good for "current record"), try either pulling it from the other form, or use for instance the openargs. Perhaps something like this:

[tt]DoCmd.OpenForm "sbfrmInvoiceER", acFormDS, , stcrit,,,Me.txtRecordNo[/tt]

Then in some relevant event in the opened form (on current?) try:

[tt]Me!txtRecordNo.Value = val(me.opernargs)
Me.Caption= "Record " & me.openargs & " Invioces"[/tt]

- add some test too on the .openargs, perhaps isnull?

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top