From one form to another

Valedlobo

New member
Local time
Today, 14:28
Joined
Dec 4, 2005
Messages
9
Hi,

I posted this in the Forms section but I wondered if it was more appropriate here.

Basically I have two forms and form 2 is opened through a button in form one, creating a new record in form2 in the process (form 2 is linked to a table, form 1 is not linked to anything).

Basically in the first form, a value is generated (QuoteValue) and I want that value to be inserted into the Amount Due textbox in form 2.

Could someone please provide some basic code to get me started.

Thanks
 
Put this in the onclick event of the button you use to open the form (and modify where appropriate):

Code:
docmd.openform "Form2"
Form2.textbox1.value = "the value
docmd.close Me.name ' close the current form

HTH
 
tkpstock said:
Put this in the onclick event of the button you use to open the form (and modify where appropriate):

Code:
docmd.openform "Form2"
Form2.textbox1.value = "the value
docmd.close Me.name ' close the current form

HTH

Getting there. Seems to run through the code OK, but then I have form2 shown and get the message that you can't reference a method if it doesn't have the focus? What do this mean please?
 
Sorry, didn't check my code.

That should be:

Code:
docmd.openform "Form2"
Forms("Form2").textbox1.value = "the value
docmd.close Me.name ' close the current form

Change the name of Form2 as appropriate.
 
Thanks.

One final point though, the outputted values in form2 are always whole numbers even if the value from form1 is a two decimal place value, any ideas why this might be? Could it be the value type (Single, Double etc) in the vb code?
 
Yes, that would be it. Make sure your textbox format is set to show the number of decimal places you want, and make sure your variable holding the value is not an integer or long (single or double is good).

HTH
 

Users who are viewing this thread

Back
Top Bottom