Access form Problem

johnnychow

Registered User.
Local time
Today, 03:32
Joined
Jul 28, 2011
Messages
20
on the red, if instead by the true value(family ID on the record) then it will work fine or randomly typing down any word then it will pop up a box saying "enter parameter value", if I type down value of family ID then it will work fine as well. But it is not what I want. I would like dynamic to get the record. Please tell me what is wrong on the code.


Private Sub Combo15_AfterUpdate()
Dim conn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sql As String
Dim i As String
Set conn = CurrentProject.Connection
sql = "select [Member].[FamilyID] from [Member] where [Member].[Surname]" & _
"like '" & Me![Combo13] & "' and [Member].[GivenName] like '" & Me![Combo15] & "'"
rst.Open sql, conn
i = rst.GetString
Me.ID = i
rst.Close
Set rst = Nothing
setfilter
End Sub



Sub setfilter()
Dim LSQL As String

LSQL = "select * from [Family]"
LSQL = LSQL & "where [Family]![FamilyID] = '" & Me.ID & "'" <<<--wrong on here, how to correct.

Form_Family.RecordSource = LSQL
End Sub
 
Have you tried:
LSQL = LSQL & "where [Family]![FamilyID] = " & Me.ID
 
thank you!!!
Can you tell me why? I am a new guy on Access.
 
The quotes were treating the value as a string (text) instead of a numerical value.
 

Users who are viewing this thread

Back
Top Bottom