Newbie needs help adding If statement to code

kirsco

Registered User.
Local time
Tomorrow, 10:16
Joined
Jul 24, 2010
Messages
12
Hi

I've been working with Access 2003 for a while, but am not so good on the code side of things.

This is the code I want to alter:

Private Sub cmdEdit_Click()
Dim stDocName As String
Dim strFilter As String
Dim stLinkCriteria As String

stDocName = "frm_Results"
strFilter = "Number= '" & Me.Number & "'"
stLinkCriteria = "frm_CIF_To_Be_Actioned"
DoCmd.OpenForm stDocName, acNormal, , strFilter, , , stLinkCriteria

End Sub

Currently on 'Click' opens "frm_Results". What I'm wanting to happen is for a particular form to be opened based on the following:

if Preventative_Reqd = -1, open "frm_ResultsPreventative, otherwise open "frm_results".

Preventative_Reqd is a yes/no field elsewhere on the form. Depending which result is in this field, I'd like either of two forms to open, all with the same click.

Is this even possible?

Any help would be greatly appreciated.
Tks, Kirsco (first post so let me know if i've done it incorrectly)
 
Put the following as shown in bold

Private Sub cmdEdit_Click()
Dim stDocName As String
Dim strFilter As String
Dim stLinkCriteria As String

if Preventative_Reqd = true then
put stdocname etc to open the form frm_ResultsPreventative
else
stDocName = "frm_Results"
strFilter = "Number= '" & Me.Number & "'"
stLinkCriteria = "frm_CIF_To_Be_Actioned"
DoCmd.OpenForm stDocName, acNormal, , strFilter, , , stLinkCriteria
end if


End Sub
 
Thanks Poppa Smurf!

That did the trick - it wasn't as difficult as I thought it would be.
:)
 

Users who are viewing this thread

Back
Top Bottom