perennial
asked on
Refresh
I have the following code. After the sql run, I need to REFRESH the database so that the following code could see the table.
I try putting me.refresh and justh refresh...it give me compile error.
Any ideas???
Function AlterTableSortId()
''Add sortId field to tblData
Dim dbs As Database
Dim myDate As String
Set dbs = OpenDatabase("Production Planning.mdb")
myDate = (InputBox("Enter Sticking Date", "Enter Date"))
CurrentDb.Execute " SELECT tblStkDat.ISNo, tblStkDat.ItemNo, tblStkDat.Size, " _
& " tblUniqueItemNoPlantName.F irstOfPlan tName, tblStkDat.DayStick, " _
& " tblStkDat.FltStick, tblBench.Bench, tblBench.BQty, tblStkDat.DatSowd, " _
& " tblUniqueItemNoPlantName.G enus, IIf([Genus]=""THYMUS"",(([ Size]*[Bqt y])*2),([S ize]*[Bqty ])) AS TotalCut, " _
& " CStr(Int(([TotalCut]*4/60/ 60/2)))+"" :""+Right( ""00"" & CStr(Int((([TotalCut]*4/60 /60/2)-Int (([TotalCu t]*4/60/60 /2)))*60+0 .5)),2) AS TotalTime " _
& " INTO tblData " _
& " FROM tblUniqueItemNoPlantName INNER JOIN (tblStkDat INNER JOIN tblBench ON " _
& " (tblStkDat.ISNo = tblBench.ItemNum) AND (tblStkDat.DayStick = tblBench.DayStick)) " _
& " ON tblUniqueItemNoPlantName.I temNo = tblStkDat.ItemNo " _
& " WHERE (((tblStkDat.DayStick)= #" & CDate([myDate]) & "# )); "
'''Refresh >>>>>>Need refresh here.
dbs.Execute "ALTER TABLE tblData " _
& "ADD COLUMN SortId Long Integer;"
dbs.Close
End Function
Thanks
perennial
I try putting me.refresh and justh refresh...it give me compile error.
Any ideas???
Function AlterTableSortId()
''Add sortId field to tblData
Dim dbs As Database
Dim myDate As String
Set dbs = OpenDatabase("Production Planning.mdb")
myDate = (InputBox("Enter Sticking Date", "Enter Date"))
CurrentDb.Execute " SELECT tblStkDat.ISNo, tblStkDat.ItemNo, tblStkDat.Size, " _
& " tblUniqueItemNoPlantName.F
& " tblStkDat.FltStick, tblBench.Bench, tblBench.BQty, tblStkDat.DatSowd, " _
& " tblUniqueItemNoPlantName.G
& " CStr(Int(([TotalCut]*4/60/
& " INTO tblData " _
& " FROM tblUniqueItemNoPlantName INNER JOIN (tblStkDat INNER JOIN tblBench ON " _
& " (tblStkDat.ISNo = tblBench.ItemNum) AND (tblStkDat.DayStick = tblBench.DayStick)) " _
& " ON tblUniqueItemNoPlantName.I
& " WHERE (((tblStkDat.DayStick)= #" & CDate([myDate]) & "# )); "
'''Refresh >>>>>>Need refresh here.
dbs.Execute "ALTER TABLE tblData " _
& "ADD COLUMN SortId Long Integer;"
dbs.Close
End Function
Thanks
perennial
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
OK - you are executing the query using CurrentDb, but your target database is dbs. Try replacing the first execute line with:
dbs.Execute " SELECT tblStkDat.ISNo, tblStkDat.ItemNo, tblStkDat.Size, " _
& " tblUniqueItemNoPlantName.F irstOfPlan tName, tblStkDat.DayStick, " _
& " tblStkDat.FltStick, tblBench.Bench, tblBench.BQty, tblStkDat.DatSowd, " _
& " tblUniqueItemNoPlantName.G enus, IIf([Genus]=""THYMUS"",(([ Size]*[Bqt y])*2),([S ize]*[Bqty ])) AS TotalCut, " _
& " CStr(Int(([TotalCut]*4/60/ 60/2)))+"" :""+Right( ""00"" & CStr(Int((([TotalCut]*4/60 /60/2)-Int (([TotalCu t]*4/60/60 /2)))*60+0 .5)),2) AS TotalTime " _
& " INTO tblData " _
& " FROM tblUniqueItemNoPlantName INNER JOIN (tblStkDat INNER JOIN tblBench ON " _
& " (tblStkDat.ISNo = tblBench.ItemNum) AND (tblStkDat.DayStick = tblBench.DayStick)) " _
& " ON tblUniqueItemNoPlantName.I temNo = tblStkDat.ItemNo " _
& " WHERE (((tblStkDat.DayStick)= #" & CDate([myDate]) & "# )); "
dbs.Execute " SELECT tblStkDat.ISNo, tblStkDat.ItemNo, tblStkDat.Size, " _
& " tblUniqueItemNoPlantName.F
& " tblStkDat.FltStick, tblBench.Bench, tblBench.BQty, tblStkDat.DatSowd, " _
& " tblUniqueItemNoPlantName.G
& " CStr(Int(([TotalCut]*4/60/
& " INTO tblData " _
& " FROM tblUniqueItemNoPlantName INNER JOIN (tblStkDat INNER JOIN tblBench ON " _
& " (tblStkDat.ISNo = tblBench.ItemNum) AND (tblStkDat.DayStick = tblBench.DayStick)) " _
& " ON tblUniqueItemNoPlantName.I
& " WHERE (((tblStkDat.DayStick)= #" & CDate([myDate]) & "# )); "
I meant to say - you are executing the *first* query using CurrentDb.
ASKER
shanesuebsahakarn,
OK, this seem to work but where did it put my table? When I go to the table it's not showing, I try to run the module again...it say that the table alreay exist.
perennial
OK, this seem to work but where did it put my table? When I go to the table it's not showing, I try to run the module again...it say that the table alreay exist.
perennial
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, that did it.
perennial
perennial
ASKER
Cannot find table or constraint.
It not seeing the newly create table.
I have to hit F5 after the module run to see the table... is there a way to do that?
perennial