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!

Another Pop-Up Form Question

Status
Not open for further replies.

sk1hotpepr

Technical User
Jul 11, 2003
63
US
I've searched on the popup form on here, and sad to say I don't quite understand the answers. Hopefully someone can enlighten me!

I have a continuous form that creates a marketing log and I have a button that when clicked will open another form in continuous view to let user enter all shortlisted firms and is linked by a marketing number. I can't think of a better way to do this since one log entry is linked to an undetermined number of shortlisted firms.

Two problems:
First, when I choose the shortlisted firm(s) I get the message that the data was added to the database but won't be displayed because it doesn't satisfy criteria.

Second, if I have multiple entries in that pop up form - when I delete a record, all of the records for that number disappear.

Please help! I'll supply any code I have if it'll help.

Thanks!
 
It sounds like you are trying to do a subform function with an external form. You will need to do a little coding for this to work.

Obviously you want a one to many relationship with the data in the shortlist form. Do you have a unique ID in the main form that identifies the record? if so you need to establish that number in the second form when you fill out the data.

I have a separate field that is invisible on my forms and when it enter data into a particular field, i place some code into the field's after Update event that goes and getsthe unique number from form one and places that into form 2. This way, when you open form two, you open it with a query withthe criteria set to the unique ID in form 1.

If you don't understand this, post me your code and I'll try and simulate the idea

"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
Jedel,
Thanks for the quick response! My Marketing Number is my Unique ID for the RFP Log.

Main Form:
MktNum (Primary Key)
School District
RFPDesc
...other fields

Linked Secondary Form:
MktNum (Shared Primary Key)
- The default value for the MktNum is set to equal the MktNum from main field textbox.
OtherFirms (Shared Primary Key)
- would an autofield work better here?

This is my code for the second form to pop up:
Dim stDocName As String
Dim stLinkCriteria As String

Me.MktNum.SetFocus
stLinkCriteria = "[MktNum]= '" & Me.MktNum.Text & "'"

stDocName = "OFirms"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thank you!

 
OK,

I think I see the issue. Yes an Autonumber in the second form would work better. Get rid of the shared primary key. I have a feeling this may be causing your heart ache.

The main form is fine, leave that. In the Secondary form, remove the primary key setting from "MktNum". Set this field property as the same as the "MktNum" on the main form (This is so there will be no Type mismatches).
Set the OtherFirms as the autonumber and make that a primary key, Although you may not need it, I found it is a good practice to place a undique record ID on every record you place in your database, you never know what the customer may want next!

The code for opening the second form looks fine, you did that with the wizard.

When you add a record to the second form, In one of the other fields, preferably a feild that normally would always require data, place the code below into the field's AfterUpdate event...

Code:
me.MktNum = Forms!MainForm!MktNum

This makes sure that the record will appear when you next open the second form.

Once you see that the MktNum field is getting the data it needs, you could then make that Field invisible if you wish.

Hope this helps

"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
With your second problem, You can use a "DELETE" SQL on a control WHERE the record matches the primary key in the second forms records (Told you that primary key would be useful!)

"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top