Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tricky form problem- "freezing" fields

Status
Not open for further replies.

osp001

Technical User
Nov 19, 2003
79
0
0
US
I am trying to construct a form to change the inventory status of items on the shelves. There are three fields; from left to right:

Item number Location Status

Under "location" and "status" fields, there are check boxes; when I enter a code into either or both of these fields, I can check the box so that it "freezes" the status. Any time I enter a new item number, for example, and "location" and "status" are frozen, the form automatically enters this value without having to manually enter it.

The idea is that I can lock those two fields and enter ONLY item numbers to change the status of a whole bunch of items at once.

The problem is that it doesn't work. I'm not much of a programmer, and the guy I asked to do this for me has been banging his head against the wall on this one.

Any suggestions as to how I might go about doing this? I can post the existing code, but I'm not sure how helpful that would be.

TIA, and sorry for such a lousy question.
 
Please post the existing code. Please also say if the form is a single form, a continuous form or a datasheet.
 
How are ya osp001 . . .
osp001 said:
[blue]Any time I enter a new item number, for example, and "location" and "status" are frozen, the form automatically enters this value without having to manually enter it[/blue]
Have a look at the controls [blue]Default Value[/blue] property! You can select any record and with a button [blue]assign defaults that will automatically appear[/blue] in new records until the button is hit again. This should alleviate the need for the checkboxes . . .

[blue]Your Thoughts?[/blue]

Calvin.gif
See Ya! . . . . . .
 
Let's see if this code comes through OK.

This is the "On Load" event procedure code for the entire form.


Option Compare Database
Option Explicit
Dim LocationToApply As String
Dim StatusToApply As String

Private Sub ApplyLocation_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyLocation Then
ApplyLocation = False
Else
ApplyLocation = True
End If
End Sub

Private Sub ApplyStatus_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyStatus Then
ApplyStatus = False
Else
ApplyStatus = True
End If
End Sub

Private Sub cmb_container_status_id_GotFocus()
If ApplyStatus Then
container_id_filter.SetFocus
End If
End Sub

Private Sub cmb_container_status_id_LostFocus()
container_id_filter.SetFocus
End Sub

Private Sub cmb_location_LostFocus()
If Not ApplyStatus Then
cmb_container_status_id.SetFocus
Else
container_id_filter.SetFocus
End If
End Sub

Private Sub container_id_filter_LostFocus()

If Not IsNull(container_id_filter.Value) Then

If Not IsNull(cmb_location.Value) Then
LocationToApply = cmb_location.Value
End If

If Not IsNull(cmb_container_status_id.Value) Then
StatusToApply = cmb_container_status_id.Value
End If

Form.RecordSource = "select * from tbl_containers where container_id = " & containier_id_filter.Value

If ApplyLocation Then
cmb_location.Value = LocationToApply
End If

If ApplyStatus Then
cmb_container_status_id.Value = StatusToApply
End If

Else
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End If

' On Error Resume Next

' If Not ApplyLocation Then
' cmb_location.SetFocus
' Exit Sub
' End If

' If Not ApplyStatus Then
' cmb_container_status_id.SetFocus
' Exit Sub
' End If

End Sub

Private Sub cmb_location_GotFocus()
If ApplyLocation Then
container_id_filter.SetFocus
End If
End Sub

Private Sub Form_Load()
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End Sub




And this is the code for the combo boxes with the check boxes:

Option Compare Database
Option Explicit
Dim LocationToApply As String
Dim StatusToApply As String

Private Sub ApplyLocation_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyLocation Then
ApplyLocation = False
Else
ApplyLocation = True
End If
End Sub

Private Sub ApplyStatus_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyStatus Then
ApplyStatus = False
Else
ApplyStatus = True
End If
End Sub

Private Sub cmb_container_status_id_GotFocus()
If ApplyStatus Then
container_id_filter.SetFocus
End If
End Sub

Private Sub cmb_container_status_id_LostFocus()
container_id_filter.SetFocus
End Sub

Private Sub cmb_location_LostFocus()
If Not ApplyStatus Then
cmb_container_status_id.SetFocus
Else
container_id_filter.SetFocus
End If
End Sub

Private Sub container_id_filter_LostFocus()

If Not IsNull(container_id_filter.Value) Then

If Not IsNull(cmb_location.Value) Then
LocationToApply = cmb_location.Value
End If

If Not IsNull(cmb_container_status_id.Value) Then
StatusToApply = cmb_container_status_id.Value
End If

Form.RecordSource = "select * from tbl_containers where container_id = " & containier_id_filter.Value

If ApplyLocation Then
cmb_location.Value = LocationToApply
End If

If ApplyStatus Then
cmb_container_status_id.Value = StatusToApply
End If

Else
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End If

' On Error Resume Next

' If Not ApplyLocation Then
' cmb_location.SetFocus
' Exit Sub
' End If

' If Not ApplyStatus Then
' cmb_container_status_id.SetFocus
' Exit Sub
' End If

End Sub

Private Sub cmb_location_GotFocus()
If ApplyLocation Then
container_id_filter.SetFocus
End If
End Sub

Private Sub Form_Load()
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End Sub
 
osp001 . . .

Did you take a look at the [blue]Default Value[/blue] property?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top