Can I use select case in this situation?

S

sandi

I have one form, frmClInfo that can be called from a dblclick and a
notinlist event.
On double click, I would like the form to open to record based on the
CaseNumber primary key.

On the notinlist I would like the add a new record with the LastName
field filled with the value from the notinlist event. (There are other
fields to be filled in on the form too)

What I have for dblclick and notinlist is:

Private Sub cboLastName_DblClick(Cancel As Integer)
If IsNull(Me!cboLastName) Then
Else
DoCmd.OpenForm "frmClInfo", , , , , , CaseNumber
End If

End Sub
_____________________

Private Sub cboLastName_NotInList(NewData As String, Response As
Integer)
Dim strsql As String, X As Integer

X = MsgBox("Do you want to add this value to the list?",
vbYesNo)
If X = vbYes Then
DoCmd.OpenForm "frmClInfo", , , , acFormAdd, acDialog,
LastName
Response = acDataErrAdded
Else
Me.cboLastName.Undo
Response = acDataErrContinue
End If

End Sub
___________________
Then OnLoad I have this:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Select Case Me.OpenArgs
Case "CaseNumber"
With Me.RecordsetClone
.FindFirst "CaseNumber='" & Me.OpenArgs & "'"
'encased in quotes because it's a string
'pass CaseID from subform to client info form
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
Case "LastName"
Me.LastName = Me.OpenArgs
CaseNumber.SetFocus
End Select
End If
End Sub

OpenArgs gets the information from the previous cbobox, but then it
passes over both case statments and goes to the end.

The clientinfo form opens but not with the correct client (if double
click event called it)
and in the second case, the client info form opens but no text in the
last name field.

The code works well if I comment out all the Select case, case... end
case statements.

What am I doing wrong?

ARRRGH!

Thanks for any help!!!
Sandi
 
B

Brian Bastl

sandi,

Here's what I'd do:

I'd eliminate the SELECT CASE statement entirely.

In the DblClick event, I'd open frmClInfo using the Where clause.

Also, I'd substitute Lastname with NewData in your OpenArgs clause in the
Not In List event .

Then in the 'called' form's On Load, you'll only have to check whether or
not an argument is being passed, and assign it to your LastName control.

Brian
 
S

sandi

Brian said:
sandi,

Here's what I'd do:

I'd eliminate the SELECT CASE statement entirely.

In the DblClick event, I'd open frmClInfo using the Where clause.

Also, I'd substitute Lastname with NewData in your OpenArgs clause in the
Not In List event .

Then in the 'called' form's On Load, you'll only have to check whether or
not an argument is being passed, and assign it to your LastName control.

Brian

Ok, so if I understand what you are saying, in the doubleclick event, I
don't use the open args position (the 7th position) of my open form
docmd?
Then in my notinlist, I do use the openarg to pass the information.
Ok will give that a try.

Thanks a lot!

Sandi
 

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