colmtourque
Registered User.
- Local time
- Today, 08:22
- Joined
- Sep 26, 2002
- Messages
- 83
Sorry, I have browed a bunch of pages looking for this, and I have it working halfway but I can't figure out the other half.
I have a form with a combo box and a button and then a subform. I want to requery the subform based on the combo box. OK, so far easy have that working. The problem is that when I add a bunch more code to the button it stops working for now I've added a second button to requery but that is a little geeky.
Button 1 Code:
Button 2 Just performs the requery, any suggestion as to why this would not be working
I have a form with a combo box and a button and then a subform. I want to requery the subform based on the combo box. OK, so far easy have that working. The problem is that when I add a bunch more code to the button it stops working for now I've added a second button to requery but that is a little geeky.
Button 1 Code:
Code:
'Declare variables edited out
If Me.ImportType.Value = "Account" Then
specname = "tblIMPAccountSpecs"
sql = "DELETE FROM tblIMPAccount"
ifn = CurrentProject.Path & "\Data\Account"
tbl = "tblIMPAccount"
ElseIf Me.ImportType.Value = "Balance" Then
specname = "tblIMPBalanceSpecs"
sql = "DELETE FROM tblIMPBalance"
ifn = CurrentProject.Path & "\Data\Balance"
tbl = "tblIMPBalance"
ElseIf Me.ImportType.Value = "Position" Then
specname = "tblIMPPositionSpecs"
sql = "DELETE FROM tblIMPPosition"
ifn = CurrentProject.Path & "\Data\Position"
tbl = "tblIMPPosition"
ElseIf Me.ImportType.Value = "Price" Then
specname = "tblIMPPriceSpecs"
sql = "DELETE FROM tblIMPPrice"
ifn = CurrentProject.Path & "\Data\Price"
tbl = "tblIMPPrice"
ElseIf Me.ImportType.Value = "Security" Then
specname = "tblIMPSecuritySpecs"
sql = "DELETE FROM tblIMPSecurity"
ifn = CurrentProject.Path & "\Data\Security"
tbl = "tblIMPSecurity"
ElseIf Me.ImportType.Value = "Transaction" Then
specname = "tblIMPTransactionSpecs"
sql = "DELETE FROM tblIMPTransaction"
ifn = CurrentProject.Path & "\Data\Transaction"
tbl = "tblIMPTransaction"
End If
DoCmd.RunSQL sql 'Empty Temp Table
DoCmd.SetWarnings False
oktogo = False
Set fs = Application.FileSearch
With fs
.LookIn = ifn
.Filename = "*.txt"
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
ShortFn = Right(.FoundFiles(i), Len(.FoundFiles(i)) - InStrRev(.FoundFiles(i), "\"))
DoCmd.TransferText acImportFixed, specname, tbl, .FoundFiles(i), True
subArchive .FoundFiles(i)
y = y + 1
Next i
Else
MsgBox "Please ensure that the source file is present and try again" & vbCr _
& "Required file location: " & vbCr & ifn, vbExclamation + vbOKOnly, "Input File Missing"
Exit Sub
End If
End With
MsgBox "Import complete. " & y & " files Imported", vbOKOnly + vbInformation, "Import Complete"
'commented because not working
'Me.frmImportData2.Form.RecordSource = "SELECT * FROM tblIMPAccount"
'Me.ctnImportData.Form.Requery
Button 2 Just performs the requery, any suggestion as to why this would not be working