Hi all
I need to take some user inputted variables and generate some new data from them. I've tried a few different ways to go about this, and I'm not really sure which is the best way to go about it (I haven't been able to get either to work).
I have a module that generates all the information I need that works fine, but I'm not sure how to get the inputted data to it.
I have a form that launched my MakeCodes module on the click event of a button, and then in that code I call a sub to get the user variables. This is where I'm confused, as I found this code through some searching and am not really sure how it works.
When I run this it opens the form for input, and (is supposed to?) wait until the form is closed to continue. When I fill in the form and close it I get an error that it can't find the form. When stepping through the loop the variables change to what I put in the form, so I'm guessing that when I close the form it is in the middle of the loop and tries to assign the variable to the control from the form, which is closed and is causing the error (the immediate window only displays "In GetUserVariables Sub"). How do I get around this?
I'm sure this isn't the best way to accomplish this task though. I was trying to do something where the submit/close event of the form would get the data and call the Sub to make my new data, but I couldn't get that working at all.
Thanks for the help
Lucas
I need to take some user inputted variables and generate some new data from them. I've tried a few different ways to go about this, and I'm not really sure which is the best way to go about it (I haven't been able to get either to work).
I have a module that generates all the information I need that works fine, but I'm not sure how to get the inputted data to it.
I have a form that launched my MakeCodes module on the click event of a button, and then in that code I call a sub to get the user variables. This is where I'm confused, as I found this code through some searching and am not really sure how it works.
Code:
Private Sub GetUserVariables()
Debug.Print "In GetUserVariables Sub"
DoCmd.OpenForm "frmInputSampleCodingVariables", acNormal
While SysCmd(acSysCmdGetObjectState, acForm, "frmInputSampleCodingVariables") = acObjStateOpen
DoEvents 'Do Nothing Wait for Closing
stBHID = Forms!frmInputSampleCodingVariables!BHID
intSampleStart = Forms!frmInputSampleCodingVariables!SampleStart
intSampleEnd = Forms!frmInputSampleCodingVariables!SampleEnd
stOreZone = Forms!frmInputSampleCodingVariables!OreZone
stSTD1 = Forms!frmInputSampleCodingVariables!STD1
stSTD2 = Forms!frmInputSampleCodingVariables!STD2
stSTD3 = Forms!frmInputSampleCodingVariables!STD3
stSTD4 = Forms!frmInputSampleCodingVariables!STD4
stSTD5 = Forms!frmInputSampleCodingVariables!STD5
Wend
End Sub
When I run this it opens the form for input, and (is supposed to?) wait until the form is closed to continue. When I fill in the form and close it I get an error that it can't find the form. When stepping through the loop the variables change to what I put in the form, so I'm guessing that when I close the form it is in the middle of the loop and tries to assign the variable to the control from the form, which is closed and is causing the error (the immediate window only displays "In GetUserVariables Sub"). How do I get around this?
I'm sure this isn't the best way to accomplish this task though. I was trying to do something where the submit/close event of the form would get the data and call the Sub to make my new data, but I couldn't get that working at all.
Thanks for the help
Lucas