views:

38

answers:

2

Ok so I hope the title of the question matches what I about to ask, but here is what I am trying to get at:

So I have an access database that uses a number of unbound forms, and the purpose of the forms are to collect data and save to various tables with VBA click events using SQL statements (INSERT or UPDATE based on whether the ID of the record is present on the form in a hidden text box). When entering a new record (via INSERT), I get the row number with

MyRow = db.openrecordset("SELECT @@Identity")(0)  'thanks David

So you maybe getting the picture. If I have another form that relates to the first form in terms of the record, I just open a recordset and pass that value to anotehr hidden text box.

So my question is, is there a better way to do this regarding passing that value (or just using that value) using a variable instead of this awkward method. So I realize a lot of folks are going to go with the obvious answer of, "Why not just make your forms bound instead of all this code"...and I am sure that is a valid answer, however I inherited this database which was already put together like this, and re-structuring it would be a duanting task.

Any and all advice, or learning resources are greatly appreciated, as they always are!

thanks justin

+1  A: 

Have you looked at OpenArgs?

 DoCmd.OpenForm "Form1", , , , , , "Hello"
Remou
would i be able to use this with unbound forms? thanks
Justin
Yes. char char c
Remou
@Remou....thanks. I really had no idea about this, but have learned some new things since investigating!
Justin
+1  A: 

I use unbound controls on forms for all these kinds of values. The current solution of using an unbound form is sounder than using global or form level variables. If I recall the details correctly while debugging code and you hit the stop button you lose all global or form level variables. Or if the user hits an unhandled error.

Tony Toews
@Tony....so is this method that I am describing above a good one would you say? Or atleast a valid way to do things?
Justin
Yes. Sigh, I need more characters to fill this comment box. And no eror message either. Jus some light grey letters at the bottom that state "12 more to go." 12 more what to go???? <grumble>
Tony Toews
hehehehehehehehe....see that was funny enough to get me to my comment quota! thanks!
Justin