coding problem

ChrisGow

Registered User.
Local time
Today, 17:34
Joined
May 9, 2005
Messages
35
Heres what I am doing.

I have a form "PO2" that when you hit a button it opens a form "FileName" that has another textbox on it and a continue button. The text box need to show a value that is calculated by code. The user is able to change this text box hit the continue button and then the value of the textbox needs to be in the "PO2" form code and the "fileName" form closes.

I also need the option that when you have the "FileName" form open you can hit a cancel button and you jsut go back to the "PO2" form. The code needs to basically stop I think.

Can anyone help me out......Im wondering if I can do this like a function where in my "PO2" form code I can set a variable to FileName=GetFileName() and then the function GetFileName() opens the form gets that value and returns it.
 
Looks like using an InputBox would be more appropriate and efficient here, no need for another form.

If you still want to use the default-calculated value when the user doesn't change, you can show the value within the InputBox dialog and ask the user whether they want to keep it as default or enter new value.
 
I'd make a custom form rather than use an InputBox. Not only do I hate them but they offer little flexibility and you can't manipulate its textbox.
 
IF I was going to use a custom form how would I get the data back from that form.
 
ChrisGow said:
IF I was going to use a custom form how would I get the data back from that form.

Create a global variable in one of your modules and set it to the value of the textbox after form closes.

Set your "fileName" = to the variable within your PO2 code.
 
Make the form popup, then when you open it your code will stop running until you close it or make it invisible.
Rather than close the form make it invisible then your code can read the value directly from the form.
Make sure that you set the forms
Record selectors, Navigation Buttons, Control box and Close Button all to No

In Form Filename have your continue/cancel buttons with this code


Code:
Private Sub btnCancel_Click()
Me.txtFileName = ""
Me.Visible = False
End Sub


Private Sub btnContinue_Click()
' do validation here
Me.Visible = False
End Sub

And in your main form use
Code:
DoCmd.OpenForm "Filename", acNormal, , , acFormAdd, acDialog
If Nz(Forms!Filename.txtFileName, "") = "" Then
    MsgBox "Cancelled", vbCritical
Else
    MsgBox Forms!Filename.txtFileName, vbCritical
End If

DoCmd.Close , "filename"

HTH

Peter
 
Thanks for the help guys.

Im having a problem that stops me from getting to this point the way I would like to.
I have a form that has a combo box that you select the source you would like to create a PO for. There is also a subform that changes when the combo box changes that has a textbox that get the ID and a yes/no box for GST for that source. This works perfectly.
What my problem is is that when I try to set ID=Form_sfrmPO2.POID.value(sub form textbox value), I get an object required error.
I tried using ID=Form_frmPO.sfrmPO2.POID.value (form sub form textbox value), I get a method or data member error.

I know that I can get the value of the combo box from the form with no problem using this exact method, but I cannot access the information on the subform.
I have no idea why, what am I doing wrong. Im sure it is something simple
 
try
Forms![frmPO]![sfrmPO2].Form![POID]

Peter
 
now i am having the same sort of problem reading data from a table.
there is only 1 record in the table that I want to read and only 1 field name.
Anyone know this problem?
Im starting to realize I know nothign about coding this stuff
 

Users who are viewing this thread

Back
Top Bottom