General discussion

Locked

Pass Variables betweent forms

By dennisbv ·
I have an access database the is used to track project status. The part I am having trouble with is passing variables between forms. I have my project form and it has a subform that displays the tasks for the related project. The project ID would be C1 and the first task would be C1-1 the second would be C1-2 and so on. Right now what I am having trouble with is on the project for I have a buttob that opend the add task form so I can add a new task for the project. What I need to do is to count the records in the subform (which works) then pass the count to the add task form so I can automaticly assign the next task ID.
So the main problem I am having is passing the value created on one form to another. I was trying to use a public varaible but I cannot get the value to pass.

Any and all help would be appreciated.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by jc2it In reply to Pass Variables betweent f ...

Use an autonumber field in the subform table and use that as your next task id. Then you don't need to worry about handling the variable. Save the project ID in a different field and combine them in the form. So that the user sees it as the C1-1, C1-2, etc... This will keep your database cleaner in the long run and make you less reliant on VB programming. This makes it easier to port to SQL when Access is too small, and incapable of multi-user access.

BTW IF you were going to use this as a primary key then you would want to make it a two field combination key. Because in your table no two records will have the same C1-1 combination, it is Unique.

Collapse -

by dennisbv In reply to

Poster rated this answer.
Although this would be a good idea it don't think it work for this situtation as I would need numbers like C1-1 or B1-1 that is the order I was given the C is corporate and the B is branch and so on.

Collapse -

by dennisbv In reply to Pass Variables betweent f ...

Let me further explain the tasks for all of the different projects are in one table so the auto number would not work for this because there could be two number 1s example the project C1 would have a project C1-1 and project C3 would have C3-1 or project D1. That is why to add a task I want to count how many tasks exist in a certain project then I take the ProjectID and append the count plus one to end up with C1-4 would come after C1-3.

Collapse -

by dennisbv In reply to Pass Variables betweent f ...

I have found information on how to do a public function. This is how I was able to pass my variable from one form and then retrieve the variable from a different form

Collapse -

by dennisbv In reply to Pass Variables betweent f ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums