Close form?? Should be simple..

A

Annemarie

Hello!

I have a simple question I just can't seem to figure out. I have the
code using an If statement to open a form when a certain value is in
the field. Have some cases where I do not want the first form to stay
open once the second appears. Can someone help me with a simple close
form code? I tried docmd.close but it was not working. I am not very
experienced with coding.

Here is what I have to open the second form...I don't know why I just
cant get this to work...When 111-10 pops up i would like the form
"Algorithm Yes" to close. This code is in the form load property for
the Algorithm Yes form. Any suggestions?

Private Sub Form_Load()

Dim stDocName1 As String
Dim stDocName2 As String

Dim stLinkCriteria As String

stDocName1 = "111-10 Tables"
stDocName2 = "116-35 Tables"


If [Forms]![add new subs]!SubCCN = "111-10" Then
stLinkCriteria = "[SubCCN]=" & "'" & Me![SubCCN] & "'"
DoCmd.OpenForm stDocName1, , , stLinkCriteria
End If
If [Forms]![add new subs]!SubCCN = "116-35" Then
stLinkCriteria = "[SubCCN]=" & "'" & Me![SubCCN] & "'"
DoCmd.OpenForm stDocName2, , , stLinkCriteria
End If

End Sub

Thanks!
 
A

Annemarie

Looks like it works so far!

Thanks so much

Annemarie

Jeff said:
DoCmd.Close acForm, "Algorithm Yes"

Hope that helps.

Hello!

I have a simple question I just can't seem to figure out. I have the
code using an If statement to open a form when a certain value is in
the field. Have some cases where I do not want the first form to stay
open once the second appears. Can someone help me with a simple close
form code? I tried docmd.close but it was not working. I am not very
experienced with coding.

Here is what I have to open the second form...I don't know why I just
cant get this to work...When 111-10 pops up i would like the form
"Algorithm Yes" to close. This code is in the form load property for
the Algorithm Yes form. Any suggestions?

Private Sub Form_Load()

Dim stDocName1 As String
Dim stDocName2 As String

Dim stLinkCriteria As String

stDocName1 = "111-10 Tables"
stDocName2 = "116-35 Tables"


If [Forms]![add new subs]!SubCCN = "111-10" Then
stLinkCriteria = "[SubCCN]=" & "'" & Me![SubCCN] & "'"
DoCmd.OpenForm stDocName1, , , stLinkCriteria
End If
If [Forms]![add new subs]!SubCCN = "116-35" Then
stLinkCriteria = "[SubCCN]=" & "'" & Me![SubCCN] & "'"
DoCmd.OpenForm stDocName2, , , stLinkCriteria
End If

End Sub

Thanks!
 

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

Top