Sam Summers
Registered User.
- Local time
- Today, 23:36
- Joined
- Sep 17, 2001
- Messages
- 939
I searched and found a couple of things on these problems but they are still not working and i am close to giving up when i can't.
I have a form with a subform on it. There is a textbox 'JobNumber' and a Label 'BaseLbl' which show the current location of items to be moved.
A combobox 'JobNo' is used to select the new location for the items (this is based on a query).
The user selects a new location and then types in the items number to a textbox 'NumberInput' and presses enter which should update the item to the new location and then update the subform to show the item at its new location and set the focus back to 'NumberInput'.
I am getting two items that move together when only one number is entered.
The subform never shows anything.
And the focus never goes back to NumberInput.
Here is the Form Code:-
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
If Forms!ViewbyLocation!Label35.Visible = True Then
Me.BaseLbl.Visible = True
Else
Me.JobNumber.Visible = True
End If
End Sub
Private Sub JobNo_Change()
Me.NumberInput.SetFocus
End Sub
Private Sub NumberInput_AfterUpdate()
Me.Refresh
Forms!Transfer!TransferLocationSubform.Form.Requery
Me.NumberInput.SetFocus
Me!NumberInput.Value = ""
Forms!ViewbyLocation.Requery
Me.NumberInput.SetFocus
End Sub
Private Sub NumberInput_BeforeUpdate(Cancel As Integer)
Dim dbs As Database, rst As Recordset
Dim strCriteria As String
Dim stDocName As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Equipment", dbOpenDynaset)
strCriteria = "[ItemNo]='" & Me.NumberInput & "'"
rst.FindFirst strCriteria
If rst.NoMatch Then
MsgBox "Number not in list Please try again", vbOKOnly, "EquiTrac"
Else
stDocName = "TransferQry"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Do Until rst.NoMatch
rst.FindNext strCriteria
Loop
End If
If IsNull(NumberInput) Or Nz(Me.NumberInput) = "" Then MsgBox "Please enter a number", vbOKOnly, "EquiTrac" Else
End Sub
*******************************
And here is the 'TransferQry' Code:-
UPDATE Equipment SET Equipment.LocationID = [Forms]![Transfer]![JobNo]
WHERE (((Equipment.ItemNo)=[Forms]![Transfer]![NumberInput]));
Thank you so much if you can point me in the right direction?
I have a form with a subform on it. There is a textbox 'JobNumber' and a Label 'BaseLbl' which show the current location of items to be moved.
A combobox 'JobNo' is used to select the new location for the items (this is based on a query).
The user selects a new location and then types in the items number to a textbox 'NumberInput' and presses enter which should update the item to the new location and then update the subform to show the item at its new location and set the focus back to 'NumberInput'.
I am getting two items that move together when only one number is entered.
The subform never shows anything.
And the focus never goes back to NumberInput.
Here is the Form Code:-
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
If Forms!ViewbyLocation!Label35.Visible = True Then
Me.BaseLbl.Visible = True
Else
Me.JobNumber.Visible = True
End If
End Sub
Private Sub JobNo_Change()
Me.NumberInput.SetFocus
End Sub
Private Sub NumberInput_AfterUpdate()
Me.Refresh
Forms!Transfer!TransferLocationSubform.Form.Requery
Me.NumberInput.SetFocus
Me!NumberInput.Value = ""
Forms!ViewbyLocation.Requery
Me.NumberInput.SetFocus
End Sub
Private Sub NumberInput_BeforeUpdate(Cancel As Integer)
Dim dbs As Database, rst As Recordset
Dim strCriteria As String
Dim stDocName As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Equipment", dbOpenDynaset)
strCriteria = "[ItemNo]='" & Me.NumberInput & "'"
rst.FindFirst strCriteria
If rst.NoMatch Then
MsgBox "Number not in list Please try again", vbOKOnly, "EquiTrac"
Else
stDocName = "TransferQry"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Do Until rst.NoMatch
rst.FindNext strCriteria
Loop
End If
If IsNull(NumberInput) Or Nz(Me.NumberInput) = "" Then MsgBox "Please enter a number", vbOKOnly, "EquiTrac" Else
End Sub
*******************************
And here is the 'TransferQry' Code:-
UPDATE Equipment SET Equipment.LocationID = [Forms]![Transfer]![JobNo]
WHERE (((Equipment.ItemNo)=[Forms]![Transfer]![NumberInput]));
Thank you so much if you can point me in the right direction?