G
Guest
I have been stumbling for too long over this one. I have a form with a Text
box and the value placed in that Text box (LotNumberTextBox) needs to be
transferred to the Report, which uses a query based on the value in the text
box. This means that I need the value to stay there and open the report,
then delete the value so the user will have an empty text box when they go
back to the form. Here is the code:
Private Sub LotNumberTextBox_Change()
'LotNumberTextBox.SetFocus
'ComponentList.Requery
Dim length$
Dim project$, box$
Dim stDocName As String
' waiting for textbox to have 16 characters
length$ = Len(CStr(LotNumberTextBox.Text))
If length$ < 16 Then
Exit Sub
End If
' end of waiting for textbox to have 16 characters
'check to see if lot number is exists in dbo_lnaLotNbrDetailALL
SQLStmt = "Select LotNbr from dbo_lnaLotNbrDetailALL as lotcheck
where LotNbr = '" + LotNumberTextBox.Text + "'"
TempDataTable.RowSource = SQLStmt
TempDataTable.Requery
Me!TempDataTable.Selected(0) = True
If IsNull(TempDataTable.Column(0, TempDataTable.ListIndex)) Then
If (MsgBox("Lot Number Does Not Exist", vbOKOnly, "Action
Aborted!") = vbOK) Then
End If
LotNumberTextBox.Value = Null
Exit Sub
End If
'end of checking to see if lot number is valid
'If lot exists in FileFolder table then we want to open the report for
location
SQLStmt = "SELECT LotFolder from FileFolder as lotcheck where
LotFolder = '" + LotNumberTextBox.Text + "'"
TempDataTable.RowSource = SQLStmt
TempDataTable.Requery
Me!TempDataTable.Selected(0) = True
If Not IsNull(TempDataTable.Column(0, TempDataTable.ListIndex))
Then
If (MsgBox("This File Folder has already been entered",
vbOKOnly, "File is already in a FC") = vbOK) Then
'Open report
DoCmd.OpenReport ("FileFolderinCarton"), acViewPreview
End If
LotNumberTextBox.Value = ""
Exit Sub
End If
'Else we want to allow user to add to an available file carton (FC)
SQLStmt = "Select LotFamily from dbo_lnaLotNbrDetailALL where LotNbr =
'" + LotNumberTextBox.Text + "'"
ComponentList.RowSource = SQLStmt
ComponentList.Requery
Me!ComponentList.Selected(0) = True
ComponentList.Value = CStr(ComponentList.Column(0,
ComponentList.ListIndex))
AvailableFCartonList.Requery
End Sub
box and the value placed in that Text box (LotNumberTextBox) needs to be
transferred to the Report, which uses a query based on the value in the text
box. This means that I need the value to stay there and open the report,
then delete the value so the user will have an empty text box when they go
back to the form. Here is the code:
Private Sub LotNumberTextBox_Change()
'LotNumberTextBox.SetFocus
'ComponentList.Requery
Dim length$
Dim project$, box$
Dim stDocName As String
' waiting for textbox to have 16 characters
length$ = Len(CStr(LotNumberTextBox.Text))
If length$ < 16 Then
Exit Sub
End If
' end of waiting for textbox to have 16 characters
'check to see if lot number is exists in dbo_lnaLotNbrDetailALL
SQLStmt = "Select LotNbr from dbo_lnaLotNbrDetailALL as lotcheck
where LotNbr = '" + LotNumberTextBox.Text + "'"
TempDataTable.RowSource = SQLStmt
TempDataTable.Requery
Me!TempDataTable.Selected(0) = True
If IsNull(TempDataTable.Column(0, TempDataTable.ListIndex)) Then
If (MsgBox("Lot Number Does Not Exist", vbOKOnly, "Action
Aborted!") = vbOK) Then
End If
LotNumberTextBox.Value = Null
Exit Sub
End If
'end of checking to see if lot number is valid
'If lot exists in FileFolder table then we want to open the report for
location
SQLStmt = "SELECT LotFolder from FileFolder as lotcheck where
LotFolder = '" + LotNumberTextBox.Text + "'"
TempDataTable.RowSource = SQLStmt
TempDataTable.Requery
Me!TempDataTable.Selected(0) = True
If Not IsNull(TempDataTable.Column(0, TempDataTable.ListIndex))
Then
If (MsgBox("This File Folder has already been entered",
vbOKOnly, "File is already in a FC") = vbOK) Then
'Open report
DoCmd.OpenReport ("FileFolderinCarton"), acViewPreview
End If
LotNumberTextBox.Value = ""
Exit Sub
End If
'Else we want to allow user to add to an available file carton (FC)
SQLStmt = "Select LotFamily from dbo_lnaLotNbrDetailALL where LotNbr =
'" + LotNumberTextBox.Text + "'"
ComponentList.RowSource = SQLStmt
ComponentList.Requery
Me!ComponentList.Selected(0) = True
ComponentList.Value = CStr(ComponentList.Column(0,
ComponentList.ListIndex))
AvailableFCartonList.Requery
End Sub