Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a Main form that can display all record. I also have a subform that allow user to add new recordset to the table.
The question that I have is how to open a main form with the new record that just added to the subform.
Below is the function:

Private Sub cmdAddNew_Click()
On Error GoTo Err_cmdAddNew_Click

'close my subform after new record is added to table
DoCmd.Close
'Close mainform to refresh data
DoCmd.Close acForm, "Mainform", acSaveYes
'Reopen the main form with the new added record
'This line is not working right.
DoCmd.OpenForm "Mainform",acViewPreview,
"Combo439 = " & LineNumber

End Sub

Any helps would be greatly appreciated.
 
If the data that is entered on the subform is displayed on the main form, why do you need a subform? Why can't you enter the data on the main form?

Mike Rohde
rohdem@marshallengines.com
 
I used the wizard to create the combo box and it only display records that are already in the table.So whenever I type a record that is not in the table, It gives me an error message said that the record is not in the list. So I need a subform in other to add a new record.But when I close the subform, I want the main form to open with the new record that I just added. So I don't have to scroll down the combobox to select the new added record.

thanks,
 
If I am understanding you correctly, this should work.

forms!mainformname!combo439.requery
forms!mainformname!combo439 = me.linenumber
Docmd.close 'close subform

This should also eliminate the need to close and reopen your subform

Mike Rohde
rohdem@marshallengines.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top