benjamin.weizmann
Registered User.
- Local time
- Yesterday, 20:01
- Joined
- Aug 30, 2016
- Messages
- 78
hi, I try write vba for export tables to excel - and I deal with some problems;
1. for every recordset this line works well:
macs - it's string
and in the origin tables , machinenum is long
only 1 recordset "remember" it expects to long and not string and I received error...(I success fix it by removing ' ) why???
2. the macs comes from listbox
in addition to this listbox, user can select checkbox to select all the machines in the listbox
so I thought to leave macs as string
and if the user select the checkbox, I pass by macs the string "IS NOT NULL"
there are more efficient ways to deal with it?
thanks
Ben
1. for every recordset this line works well:
Code:
WHERE [machinenum]='" & macs & "'
and in the origin tables , machinenum is long
only 1 recordset "remember" it expects to long and not string and I received error...(I success fix it by removing ' ) why???
Code:
strSQL = "SELECT IDeventask as îæää_àéøåò, ID_task AS îæää_îùéîä, name_task as ùí_îùéîä , duedate_task as úàøéê_çæåé, dodate_task as úàøéê_áéöåò, result_task as úåöàä ,okornot as _ú÷éï, statustask as ÷åã_ñèàèåñ, stat as ñèàèåñ , tasks_diary.machinenum as ùí_îëåðä, production_diary1.lognum as îæää_çéáåø, worker_pro AS òåáã, date_pro AS úàøéê_îùîøú " _
& " FROM ((tasks_diary LEFT JOIN production_diary1 ON tasks_diary.lognum=production_diary1.lognum) LEFT JOIN tasks ON tasks_diary.ID_task=tasks.ID) LEFT JOIN status ON tasks_diary.statustask=status.ID" _
& " WHERE tasks_diary.[machinenum]='" & macs & "' AND [worker_pro]='" & works & "' AND [date_pro]>=#" & Format(starts, "yyyy/mm/dd hh:nn:ss") & "# AND [date_pro]<=#" & Format(endds, "yyyy/mm/dd hh:nn:ss") & "#;"
in addition to this listbox, user can select checkbox to select all the machines in the listbox
so I thought to leave macs as string
and if the user select the checkbox, I pass by macs the string "IS NOT NULL"
there are more efficient ways to deal with it?
thanks
Ben