First VBA. EVER. Help?

GADTG

Registered User.
Local time
Yesterday, 16:46
Joined
Aug 26, 2012
Messages
43
I think I understand the theory of what I'm trying to do here, but being brand spankin new to VBA I've only got half of the idea working so far:

I have a Project form, which holds StockArtProduction_Subform in datasheet view. I have it able to click on the ID in the StockArtProduction_Subform datasheet and it open a single view form (StockArtProduction) with the correlating ID thanks to this code

DoCmd.OpenForm "FStockArtProduction", , , "ID = " & Me.ID

YAY (thanks PBaldy)! But now I need a resolution for new entries of the StockArtProduction_Subform in datasheet view. My theory is something along the lines of:

If ID is null then open form StockArtProduction with new entry where ProjectID = ProjectID from Projects that is currently open.

But for some reason that didn't work when I plugged it in :rolleyes:.

Please please please help. This is literally the last step other than clean up in this saga of a database. This forum has been invaluable and I can not thank everyone enough for that.
 
Last edited:
Not clear what the situation is, but you can test for the ID being Null like:

If IsNull(Me.ID) Then

or

If Me.NewRecord Then

to test for the record on the form being new. If you need to push a value to the just-opened form:

Forms!NewFormName.ControlName = Me.ControlName
 
Let me see if I can better explain because I soooo appreciate your help and don't want to waste your time. I'm going to try to get us on the same page.

We are an apparel printer. We (brilliantly or stupidly, I'm not sure which yet) specialize in offering 10 in-house printing processes. So often our projects are a little of this (say, screen-printing), a little of that (embroidery) and it's got all the makings of a disaster. The form is the Project as a whole, and the subform (StockArtProduction_Subform) is a datasheet preview of what was ordered within that project (each has it's own stock, art and production process). What you helped me achieve ealier was to click on the StockArtProduction_Subform ID and open the correlating StockArtProduction form so that we can see all the lovely details (THANK YOU). What I need now is to allow an employee to have a Project open, and be able to click-- on anything really-- to open a new record for StockArtProduction that has the same ProjectID as the Project they are in.

With that, my life will be complete and I will happily send you lots of thank you t-shirts.
 
So the linking method wouldn't work because there is no existing record? You could do something like this:

DoCmd.OpenForm "StockArtProduction", acNormal, , , acFormAdd
Forms!StockArtProduction.ProjectID = Me.ProjectID

The first line opens the form in data entry mode, so you know it will be on a new record, the second copies the ProjectID field from the form you're on to the form you're opening. Does that sound like what you're after?
 
YESSSSSSSSSSSSSS!! Paul, you are my hero today! Do I need to separate it in any way from DoCmd.OpenForm "FStockArtProduction", , , "ID = " & Me.ID? Or just put it in there right afterwards?
 
Just as I have them should work, changing to your textbox names if different. Okay, now when does the truckload of t-shirts get here? :p
 
Seriously- send me your info and we'll send you something! It's the least we can do. Our team thanks you!!
 
Nah, I was only kidding around. I enjoyed helping. I hope it works for you.
 
We would love to send you goodies for you and your family- please send me a PM! It'll make us all so happy sharing what we do with someone who helped us do it better.

But YES so far it looks BEAUTIFUL. And you know you'll hear from me if something goes nuts lol.
You rock my socks off. Period.
-Lindsey and The 42nd Floor Team.
 

Users who are viewing this thread

Back
Top Bottom