Multi IF Statement

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

Guest

The "Yes" and " No" conditions work well. I want to add an "Add" button with the condition to add another record even thought it's a duplicate. Can someone help?

Here is my code that needs the "add" condition:

Dim rs As DAO.Recordset ' be sure Tools... References has DAO checked
Dim iAns As Integer
Set rs = Me.RecordsetClone
rs.FindFirst "[MEDREC] = '" & Me!MEDREC & "' And [DOCCRS]= #" & Me!DOCCRS & "#"

If Not rs.NoMatch Then
iAns = MsgBox("This record already exists! Jump to it?", vbYesNo)
If iAns = vbYes Then
' Clear the current form, jump to the record
Me.Undo
Cancel = True
Me.Bookmark = rs.Bookmark
Else
' Just clear the medicalrecord textbox, let them try again
Cancel = True
Me!MedicalRecord.Undo
End If
End If
 
So, actually, your real problem you need a MsgBox with 3 choices....and you
don't have that..do you?

So, is your problem creating a custom msgbox with 3 choices...or the code
that follows?

Lets assume you make your own custom menu MsgBox with 1 choices, you could
then go:

iAns = MyMsgBox("This record already exists! Jump to it?")
If iAns = 1 Then
' yes
' Clear the current form, jump to the record
Me.Undo
Cancel = True
Me.Bookmark = rs.Bookmark
end if
if iAns = 2 then
' no
' Just clear the medicalrecord textbox, let them try again
Cancel = True
Me!MedicalRecord.Undo
End if

if iAns = 3 then
' add
just let the user add..do nothing?
endif

The above could/should be a select case statment like:

begin case
select case iAnse

case 1
' yes
' Clear the current form, jump to the record
Me.Undo
Cancel = True
Me.Bookmark = rs.Bookmark

case 2
' no
' Just clear the medicalrecord textbox, let them try again
Cancel = True
Me!MedicalRecord.Undo

case 3
' add
just let the user add..do nothing

end select

So, build your own custom little prompt routine that works just like the
MsgBox command. It is very easy to do this, and you could wrap the whole
process in a nice little function like MyMsgBox.

You do need to know about how to use a dialog form to return values. Here is
how to do that:
http://www.attcanada.net/~kallal.msn/Dialog/Index.html
 
Back
Top