Open Subform equal to Main Form Record in Access Project - SQL bac

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have used the following code which works great, the only thing is that I
want my subform to open as a dialog form.

Private Sub Inactivate_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_Inactivate_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![Company_Name]) Then
strMsg = "Move to the vendor record you want to see, then press the
Inactivate button again."
intStyle = vbOKOnly
strTitle = "Select a Vendor"
MsgBox strMsg, intStyle, strTitle
Me![Company_Name].SetFocus
Else
' Otherwise, open Inactivate Vendor form for current vendor.
strDocName = "POP:Company_Inactivation"
strLinkCriteria = "Company_ID = " +
CStr(Forms![F:Vendor_Entry]![Company_ID])

DoCmd.OpenForm strDocName

Forms![POP:Company_Inactivation].Filter = strLinkCriteria
Forms![POP:Company_Inactivation].FilterOn = True

End If

Exit_Inactivate_Click:
Exit Sub

Err_Inactivate_Click:
MsgBox Err.Description
Resume Exit_Inactivate_Click

End Sub

If I use DoCmd.OpenForm strDocName, acNormal, ,
Forms![POP:Company_Inactivation].Filter = strLinkCriteria, acFormEdit,
acDialog
the form comes up in dialog mode but the filter is not applied. I am
stumped! Any suggestions would be appreciated.

Thanks!
 
Hi Wendyhnc, use the windowmode argument (combine with form properties of
centre =yes and resize=yes). The example below uses named arguments...

DoCmd.OpenForm FormName:=strDocName, WindowMode:=acDialog

Luck
Jonathan
 
That's the same issue I was having with the regular openform command, the
form opens in dialog mode but the filter is not applied.
 
wendyhnc said:
That's the same issue I was having with the regular openform command, the
form opens in dialog mode but the filter is not applied.

wendyhnc said:
I have used the following code which works great, the only thing is that I
want my subform to open as a dialog form.

Private Sub Inactivate_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_Inactivate_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![Company_Name]) Then
strMsg = "Move to the vendor record you want to see, then press the
Inactivate button again."
intStyle = vbOKOnly
strTitle = "Select a Vendor"
MsgBox strMsg, intStyle, strTitle
Me![Company_Name].SetFocus
Else
' Otherwise, open Inactivate Vendor form for current vendor.
strDocName = "POP:Company_Inactivation"
strLinkCriteria = "Company_ID = " +
CStr(Forms![F:Vendor_Entry]![Company_ID])

DoCmd.OpenForm strDocName

Forms![POP:Company_Inactivation].Filter = strLinkCriteria
Forms![POP:Company_Inactivation].FilterOn = True

End If

Exit_Inactivate_Click:
Exit Sub

Err_Inactivate_Click:
MsgBox Err.Description
Resume Exit_Inactivate_Click

End Sub

If I use DoCmd.OpenForm strDocName, acNormal, ,
Forms![POP:Company_Inactivation].Filter = strLinkCriteria, acFormEdit,
acDialog
the form comes up in dialog mode but the filter is not applied. I am
stumped! Any suggestions would be appreciated.

Thanks!

Hi Wendy,
try...

DoCmd.OpenForm FormName:=strDocName, _
WhereCondition:=strLinkCriteria, _
WindowMode:=acDialog

that is, open the form with the filter applied. Any code following this will
not run until the form is closed (because of the window mode).

Luck
Jonathan
 
Awesome! Thank you so much, it worked like a charm. Have a wonderful day!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top