对不起伙计们,再次问好。不是程序员,试图搞砸了。
我的搜索记录工作正常。
def addDateColumn():
"""Adds time to the daily rainfall data. Reads the csv as chunks of 100k
rows at a time and outputs them, appending as needed, to a single csv.
Uses the column of the raster names to get the date.
"""
df = pd.read_csv(pathlist[1]+"CHIRPS_tanz.csv", iterator=True,
chunksize=100000) #read csv file as 100k chunks
'''Do some stuff'''
count = 1 #for indexing item in time list
for chunk in df: #for each 100k rows
newtime = [] #empty list to append repeating times for different rows
toiterate = chunk[chunk.columns[2]] #ID of raster nums to base time
while count <= toiterate.max():
for i in toiterate:
if i ==count:
newtime.append(newyears[count])
count+=1
print "Finished", str(chunknum), "chunks"
chunk["time"] = newtime #create new column in dataframe based on time
outname = "CHIRPS_tanz_time2.csv"
#append each output to same csv, using no header
chunk.to_csv(pathlist[2]+outname, mode='a', header=None, index=None)
新的复杂功能现在用于打开新记录,因为不符合标准。当找不到记录时,我希望它强制用于搜索shiftdate和shift字段的两个变量。通过这种方式,我可以锁定这些字段并限制我的用户在相同的日期和班次上进行十亿次操作。它总是将它们引导到当前创建的一个,或者如果它不可用则创建一个新的。
我试过
Dim Date1 As String
Dim Shift1 As String
Date1 = Text6.Value
Shift1 = List12.Column(1)
DoCmd.OpenForm "Data", , , "Data![ShiftDate] = #" & Date1 & _
"# AND Data![Shift] ='" & Shift1 & "'"
因此,每次找到记录或创建新记录时,它都会与日期匹配。可能不是最有效的,但它应该做我需要的。但是,我在其他问题中遇到 424错误代码。任何人都知道为什么它不会接受我在找到/创建的记录中输入的字段?
答案 0 :(得分:1)
只需测试+检查记录是否存在,然后将表单打开到记录中,或者只需在添加模式下打开表单。
这应该可以解决问题:
Dim strWhere As String
Dim Date1 As String
Dim Shift1 As String
Date1 = Test6.Value
Shift1 = List12.Column(1)
strWhere = "Data![ShiftDate] = #" & Date1 & _
"# AND Data![Shift] ='" & Shift1 & "'"
If DCount("*", "tblShifts", strWhere) > 0 Then
' record exist, simply open the form
DoCmd.OpenForm "Data", , , strWhere
Else
' record does NOT exist, open form in add mode
DoCmd.OpenForm "Data", , , , acFormAdd
'
' setup the two default values
Forms!Data!ShiftDate = Date1
Forms!Data!Shift1 = Shift1
End If
答案 1 :(得分:0)
您的424错误是因为使用=
需要=
两侧的对象,而Data![shiftdate].Value
不是对象。我想你需要的是:
Me.shiftdate = Date1