PC Review


Reply
Thread Tools Rate Thread

Can't open form using listbox non-bound column

 
 
Nick Mirro
Guest
Posts: n/a
 
      21st Oct 2003
When a listbox (lstRecentPatients) row is clicked it opens another form
(based on option group selection) to the matching record using the code
below.


If option group "FormToOpen" is 1, the correct form opens, but the subform
record desired is not displayed.

If option group "FormToOpen" isn't 1, then it hangs on the ***OpenForm
command.


I created a command button to duplicate this "isn't 1" action and got this
error:

"Syntax error in string in query expression '[VisitID]=""



Private Sub lstRecentPatients_AfterUpdate()

If FormToOpen = 1 Then

Dim frm As Form

DoCmd.OpenForm "frmCollections", _
WhereCondition:="PatientID=" & Me![lstRecentPatients]

Set frm = Forms!frmCollections!sbfrmCollections.Form

With frm.RecordsetClone
.FindFirst "VisitID=" & Me!lstRecentPatients.Column(10)
If Not .nomatch Then
frm.Bookmark = .Bookmark
End If
End With

Set frm = Nothing

End If

If Not FormToOpen = 1 Then

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmReceivePayments"

stLinkCriteria = "VisitID=" & "'" & Me!lstRecentPatients.Column(10)
& "'"
***DoCmd.OpenForm stDocName, , , stLinkCriteria

End If

End Sub



I would greatly appreciate being shown the error causing problems with this.

Nick


 
Reply With Quote
 
 
 
 
Nick Mirro
Guest
Posts: n/a
 
      21st Oct 2003
Forgot to refer to column as -1 the position. Now it works : )


"Nick Mirro" <(E-Mail Removed)> wrote in message
news:u293GV%(E-Mail Removed)...
> When a listbox (lstRecentPatients) row is clicked it opens another form
> (based on option group selection) to the matching record using the code
> below.
>
>
> If option group "FormToOpen" is 1, the correct form opens, but the subform
> record desired is not displayed.
>
> If option group "FormToOpen" isn't 1, then it hangs on the ***OpenForm
> command.
>
>
> I created a command button to duplicate this "isn't 1" action and got this
> error:
>
> "Syntax error in string in query expression '[VisitID]=""
>
>
>
> Private Sub lstRecentPatients_AfterUpdate()
>
> If FormToOpen = 1 Then
>
> Dim frm As Form
>
> DoCmd.OpenForm "frmCollections", _
> WhereCondition:="PatientID=" & Me![lstRecentPatients]
>
> Set frm = Forms!frmCollections!sbfrmCollections.Form
>
> With frm.RecordsetClone
> .FindFirst "VisitID=" & Me!lstRecentPatients.Column(10)
> If Not .nomatch Then
> frm.Bookmark = .Bookmark
> End If
> End With
>
> Set frm = Nothing
>
> End If
>
> If Not FormToOpen = 1 Then
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "frmReceivePayments"
>
> stLinkCriteria = "VisitID=" & "'" &

Me!lstRecentPatients.Column(10)
> & "'"
> ***DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> End If
>
> End Sub
>
>
>
> I would greatly appreciate being shown the error causing problems with

this.
>
> Nick
>
>



 
Reply With Quote
 
Emilia Maxim
Guest
Posts: n/a
 
      26th Oct 2003
"Nick Mirro" <(E-Mail Removed)> wrote:

>If option group "FormToOpen" is 1, the correct form opens, but the subform
>record desired is not displayed.
>
>If option group "FormToOpen" isn't 1, then it hangs on the ***OpenForm
>command.


>I created a command button to duplicate this "isn't 1" action and got this
>error:
>
> "Syntax error in string in query expression '[VisitID]=""


>Private Sub lstRecentPatients_AfterUpdate()
>
> If FormToOpen = 1 Then
>
> --- snip ---
> End If
>
> If Not FormToOpen = 1 Then
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "frmReceivePayments"
>
> stLinkCriteria = "VisitID=" & "'" & Me!lstRecentPatients.Column(10)
>& "'"
> ***DoCmd.OpenForm stDocName, , , stLinkCriteria


Nick,

as I see further above, the VisitID is probably numerical, so leave
out the quotes:

stLinkCriteria = "VisitID=" & Me!lstRecentPatients.Column(10)

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert MonthName back to Number or create invisible bound column in listbox Bob Microsoft Access 1 29th Mar 2007 02:16 PM
Listbox Bound Column Problem =?Utf-8?B?TG93cmlkZXI3Mg==?= Microsoft Access Form Coding 1 12th Oct 2005 09:46 PM
Textbox bound to Listbox column... How to edit data? Grahammer Microsoft Access Forms 1 27th Oct 2004 08:21 PM
Multi-column ListBox. Multiple bound columns??? =?Utf-8?B?Sm9lIE1hdGhpcw==?= Microsoft Excel Programming 5 10th Dec 2003 01:32 AM
Referencing ID column in ListBox bound to DataTable Young J. Putt Microsoft VB .NET 2 26th Nov 2003 10:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:14 AM.