Filtering values (1 Viewer)

srav006

New member
Local time
Yesterday, 20:36
Joined
Feb 24, 2017
Messages
5
Hi All,

Could you please help me on the below code..

is anything i am missing?

having error on 3 rd line" Data type mismatch in criteria expression.

The "Customer number is short text in Table.

Code:
Private Sub Combo2_AfterUpdate()
Dim Org As Variant
    Org = "Select * from StoreDat where ([Customer Number] = " & Me.Combo2 & ")"
    Me.StoreDat_subform.Form.RecordSource = Org
    Me.StoreDat_subform.Form.Requery
End Sub

Thanks for your help in advance...

regards
Sock
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:36
Joined
Aug 30, 2003
Messages
36,118
You need delimiters for text. At the simplest:

Org = "Select * from StoreDat where ([Customer Number] = '" & Me.Combo2 & "')"
 

srav006

New member
Local time
Yesterday, 20:36
Joined
Feb 24, 2017
Messages
5
Hi Thanks for your reply..

its working but it will not pulling any data in subform..

i have attached the database for your reference.

Thanks
 

Attachments

  • Test_Database.accdb
    584 KB · Views: 99

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:36
Joined
Aug 30, 2003
Messages
36,118
Because the customer number is not the bound column of the combo. You can drop the ID field, or get the second column:

Srh = "Select * from Tbl_Store where ([CustomerNumber] = '" & Me.Combo2.Column(1) & "')"
 

srav006

New member
Local time
Yesterday, 20:36
Joined
Feb 24, 2017
Messages
5
That works...Thanks..

i can use the same code for all the Value which is in "Short text" right?

regards
Socrates
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:36
Joined
Aug 30, 2003
Messages
36,118
Happy to help!
 

Users who are viewing this thread

Top Bottom