Open form from another form

Real Wally

Registered User.
Local time
Today, 22:21
Joined
Jan 28, 2003
Messages
107
Hi,

I'm trying to open a new record form from another form.

This is the code I came up with that dosn't work

DoCmd.OpenForm "frmSingleNoteOnPatent", acNormal, , , "PublicationID = " & Me.PublicationID
DoCmd.GoToRecord , , acNewRec

I get error message "type mismatch"

I don't understand that. Both form have the same PublicationID field (number field).

Anybody any clue?

Thanks,

Wally
 
Just one line:

Code:
DoCmd.OpenForm "frmSingleNoteOnPatent", acNormal, , , acFormAdd
 
The line above will negate the need to open the form on a specific record and then add a new record - it goes to the new record within that's form's recordset immediately.

As for your type mismatch, it could just be a quirk of the form where your publicationID is in a textbox and therefore is being treated as text. THe CLng() function may remedy that.

i.e.

Code:
"PublicationID = " & CLng(Me.PublicationID)
 
Thanks Mile-O-Phile,

I'm still having no luck though.

The first line of code opens the correct form OK but won't let me enter data. looking more closely at the qry this form is based on I see that I have 2 autonumbers in it. That's not allowed is it?
I'll change my qry and will try again. If that doesn't get me there I'll post again.

Thanks,

Wally
 
I think I haven't explained that I'm using 2 tables here:

tblPatents (contains the field PublicationID)
tblNotesOnPatent

The button on frmNotes opens the notes specific for that PublicationID record.

What I'd like to achieve is that a button on on that form opens another form to enter a new note. Name of that form is "frmSingleNoteOnPatent".
I am hoping that it's possible to directly have new note linked to the correct PublicationID.

I don't think Mile's code does that, not in my hands anyway.

Thanks,

Wally
 

Users who are viewing this thread

Back
Top Bottom