VBA Program

Copper Contributor

Hi Friends 

I am new to this forum and this is my first post. Please bear with me If I make a mistake .

I have developed a small VBA program with two forms Main from and addProduct form . In this VBa program when I click a button in main form AddItem form should be visible and when I click Return button in addproduct form main form should be visible . However there is an error Message "Can't show non model form when model form is displayed" kindly help me to solve this issue

3 Replies
Try the following idea:
'Main form
Private Sub cmdProductform_Click()
On Error GoTo Err_cmdProductform_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmProduct"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdProductform_Click:
Exit Sub

Err_cmdProductform_Click:
MsgBox Err.Description
Resume Exit_cmdProductform_Click

End Sub

'Product form
Private Sub cmdCloseMe_Click()
On Error GoTo Err_cmdCloseMe_Click


If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_cmdCloseMe_Click:
Exit Sub

Err_cmdCloseMe_Click:
MsgBox Err.Description
Resume Exit_cmdCloseMe_Click

End Sub
Thanks For your reply . I get below msg when I run the code pls
" Compile Error Variable not Defined"
'Main form
Private Sub cmdProductform_Click()
On Error GoTo Err_cmdProductform_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmProduct"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdProductform_Click:
Exit Sub

Err_cmdProductform_Click:
MsgBox Err.Description
Resume Exit_cmdProductform_Click

End Sub

@Upaliwije 

Attached herewith My project file please