Receiving field keeps reverting to numeric (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 01:26
Joined
May 13, 2014
Messages
348
I have a search option and the field where the search criteria goes into keeps changing from a string to numeric


If I activate the Order No, the second field from the right changes the caption to Order No. and then the last field (cmbFilter) is where the user places in the value. In this case the input mask makes the uswer start entering data from the left in the cmbFilter.
Search Panel.JPG


I do this for the Supplier and no problem and for a date it reverts to the user being forced to enter the date value from the right hand end of the field, or I try and
use the Order No option and I have to enter the data from the right hand side of the cmbFilter field

The panel with the radio buttons is named OptionsFrm and the After Update event is
Code:
Private Sub OptionsFrame_AfterUpdate()
Dim bolVisible As Boolean
Dim strSource As String
bolVisible = (Me.OptionsFrame > 0)
With Me.cbmFilter
    '.Visible = bolVisible
    Select Case Me.OptionsFrame
        Case 1
            strSource = "select OrderNo from OrdersOnlyQry group by OrderNo Order By OrderNo;"
            Me.FilterLbl.Caption = "Order No"
            Me.FilterLbl.Width = 1248
            Me.cbmFilter.InputMask = "00000;0;"
            sFilter = "OrderNo = 'p1'"
        Case 2
            strSource = "select Supplier from OrdersOnlyQry group by Supplier Order By Supplier;"
            Me.FilterLbl.Caption = "Supplier"
            Me.FilterLbl.Width = 1248
            Me.cbmFilter.InputMask = ""
            sFilter = "Supplier = 'p1'"
        Case 3
            strSource = "select DateOrdered from OrdersOnlyQry group by DateOrdered Order By DateOrdered;"
            Me.FilterLbl.Caption = "Date Ordered"
            Me.FilterLbl.Width = 1450
            Me.cbmFilter.InputMask = ""
            sFilter = "DateOrdered = #p1#"
        Case 4
            strSource = "select DateArrived from OrdersOnlyQry group by DateArrived Order By DateArrived;"
            Me.FilterLbl.Caption = "Date Arrived"
            Me.FilterLbl.Width = 1361
            Me.cbmFilter.InputMask = ""
            sFilter = "DateArrived = #p1#"
        Case Else
            ' ------------ should not get here --------------------------
            MsgBox " Using the default Order No. Option"
            strSource = "select OrderNo from OrdersOnlyQry group by OrderNo Order By OrderNo;"
            Me.FilterLbl.Caption = "Order No."
            Me.FilterLbl.Width = 1248
            Me.cbmFilter.InputMask = "00000;0;"
            sFilter = "OrderNo = 'p1'"
        
    End Select
    .RowSource = strSource
End With
If oldValue <> Me.OptionsFrame Then
    Me.cbmFilter = ""
    oldValue = Me.OptionsFrame
    Me.FilterOn = False
End If
End Sub

-------------------------------------
The cmbFilter field afterUpdate event is

Code:
Private Sub cbmFilter_AfterUpdate()
Dim thisFilter As String
If Len(Me.cbmFilter & vbNullString) > 0 Then
    thisFilter = Replace(sFilter, "p1", Me.cbmFilter)
    Me.Filter = thisFilter
    Me.FilterOn = True
    Me.Requery
Else
    Me.FilterOn = False
End If
End Sub

What can I do to make sure the cmbFilter field stays as a string field

Any help will be a bonus
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:26
Joined
May 7, 2009
Messages
19,233
did you declare variable sFilter?

option explicit
Dim sFilter As String
 

atrium

Registered User.
Local time
Tomorrow, 01:26
Joined
May 13, 2014
Messages
348
Yes I did
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:26
Joined
Feb 19, 2013
Messages
16,607
standard text is entered from the left, numbers from the right (and dates are numbers)

have you tried setting the text align property to left?
 

atrium

Registered User.
Local time
Tomorrow, 01:26
Joined
May 13, 2014
Messages
348
No I haven't but I will - Thank you
 

JonXL

Active member
Local time
Today, 10:26
Joined
Jul 9, 2021
Messages
153
Is it cbm or cmb? Not sure that's really the problem (I would suspect something like that not to compile) but it'll be easy to check to be sure.
 

Users who are viewing this thread

Top Bottom