Textbox code works, combobox code doesnt? (1 Viewer)

Rick Stanich

King and Supreme Ruler
Local time
Today, 13:09
Joined
May 13, 2009
Messages
93
I use practically the same code for a textbox that I do for a combobox.
Due to my inexperience, I dont know why this wont work.
Textboxes:
Code:
Private Sub Check32_Click()
If Check32.Value = True Then
    varSettings = GetSetting("GeoMeasure", "CMM Data", "sPartNumber")
    If varSettings = "" Then
        MsgBox "No value for Part Number stored in registry."
        Me.sPartNumber.SetFocus
    Else
        Me.sPartNumber.SetFocus
        sPartNumber.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="sPartNumber")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "sPartRev")
    If varSettings = "" Then
        MsgBox "No value for Part Revision stored in registry."
        Me.sPartRev.SetFocus
    Else
        Me.sPartRev.SetFocus
        sPartRev.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="sPartRev")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "sJobNo")
    If varSettings = "" Then
        MsgBox "No value for Job Number stored in registry."
        Me.sJobNo.SetFocus
    Else
        Me.sJobNo.SetFocus
        sJobNo.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="sJobNo")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "sSerialNo")
    If varSettings = "" Then
        MsgBox "No value for Serial Number stored in registry."
        Me.sSerialNo.SetFocus
    Else
        Me.sSerialNo.SetFocus
        sSerialNo.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="sSerialNo")
    End If
Else
    Me.sPartNumber.SetFocus
    sPartNumber.Value = ""
    Me.sPartRev.SetFocus
    sPartRev.Value = ""
    Me.sJobNo.SetFocus
    sJobNo.Value = ""
    Me.sSerialNo.SetFocus
    sSerialNo.Value = ""
End If
End Sub
When Check32 = True the textboxes are populated with last known data. :cool:

Comboboxes:
Code:
Private Sub Check33_Click()
If Check33.Value = True Then
    varSettings = GetSetting("GeoMeasure", "CMM Data", "Combo1")
    If varSettings = "" Then
        MsgBox "No value for Part Number stored in registry."
        Me.Combo1.SetFocus
    Else
        Me.Combo1.SetFocus
        Me.Combo1.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="Combo1")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "Combo2")
    If varSettings = "" Then
        MsgBox "No value for Part Revision stored in registry."
        Me.Combo2.SetFocus
    Else
        Me.Combo2.SetFocus
        Me.Combo2.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="Combo2")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "Combo3")
    If varSettings = "" Then
        MsgBox "No value for Job Number stored in registry."
        Me.Combo3.SetFocus
    Else
        Me.Combo3.SetFocus
        Me.Combo3.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="Combo3")
    End If
    varSettings = GetSetting("GeoMeasure", "CMM Data", "Combo4")
    If varSettings = "" Then
        MsgBox "No value for Serial Number stored in registry."
        Me.Combo4.SetFocus
    Else
        Me.Combo4.SetFocus
        Me.Combo4.Value = GetSetting(AppName:="GeoMeasure", section:="CMM Data", _
                Key:="Combo4")
    End If
Else
    Me.Combo1.SetFocus
    Combo1.Value = ""
    Me.Combo2.SetFocus
    Combo2.Value = ""
    Me.Combo3.SetFocus
    Combo3.Value = ""
    Me.Combo4.SetFocus
    Combo4.Value = ""
End If
End Sub
When Check33 = True the comboboxes are blank. :confused:

What do I have wrong?
 

DCrake

Remembered
Local time
Today, 21:09
Joined
Jun 8, 2005
Messages
8,632
Have you stepped through the code to find out what it is doing?

David
 

Rick Stanich

King and Supreme Ruler
Local time
Today, 13:09
Joined
May 13, 2009
Messages
93
Using message boxes to see values of each, shows the correct value saved in the registry for each combobox.
I just cant get the values (.Value or .Text) to show up in the combobox..

Code:
MsgBox Me.Combo1.Value
Displays the correct value.

Note:
Using "Me.Combo1.Text" yeilds an error and places the value in the combobox (after the error?).

Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule for this field
is preventing Microsoft Access from saving the data in the field.
 

Rx_

Nothing In Moderation
Local time
Today, 14:09
Joined
Oct 22, 2009
Messages
2,803
Exact same issue!
Searching for an answer, have spent a day on this.
Opening up the _be database, the last data field is blank. the Me.dirty is true.
Sometime, I run the me.refresh - and it fills in, other times it doesn't.
Hope to find an answer elsewhere. Or if someone reads this, I will be watching.
Access 2008
 

Rx_

Nothing In Moderation
Local time
Today, 14:09
Joined
Oct 22, 2009
Messages
2,803
http://www.access-programmers.co.uk/forums/showthread.php?t=168778&highlight=error+2115
great link as how to catch this error. This helped identify the problem.

Just a followup:
The customer wants tab controls with lots of logic, not command buttons for confirm and that kind of thing.
Hopefully, this kind of customer requirement will be rare.
Again, when I had the same code in a cmdButton, no problem.
This problem goes away when the network is fast.
It re-appears later. Sometimes taking 15 seconds for the last field to fill in. I worked until 7 PM last night, could not get an error for the last hour.
This morning, came in early, no error.
At 9:00, if I hurried to the next command or entry... random errors.
Always the last field from the last combo list box.


But, the combo box just won't update the underlying record!
Not until I manually click off of it.
even the recrodset edit/update doesn't error, but seems to be blocked by the bound property.

Problem:
Bookmark existing record
Add new record
Three combo boxes required to be filled in (due to logic situations) and then accept, go back and edit more, or Delete work in progress.
The delete - deletes the existing record, uses book mark to go back.

Cause of problem:
A function checked to see that all theree list boxes had a value once a new record was put in. The problem is that the record underneath had a field not being updated. The me.dirty showed to be false.
the message comes from the form level as seen in the excellent link above.
In retrospect, my function to check should have checked to see that all three fields in the new record were completed.
It is fustrating. I can see the record set has a value, the list box shows a value, but when I open up the _be the bound field is null.
Nothing I do will force an update including the recordset.edit, set a value, and recordset.update
If I manually click on another list box, then it will update.
 
Last edited:

Users who are viewing this thread

Top Bottom