Tema: Re: Q: Access (html)
Autorius: Jornada Del Muerto
Data: 2010-02-09 17:44:51
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18865">
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Calibri>Pabandysiu surasyti taip kad butu patogiau 
skaityti.</FONT></DIV>
<DIV><FONT face=Calibri><EM></EM></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><EM>Nepamenu dabar o datai neina accesse 
<STRONG>DateTime Picker </STRONG>naudot? tai tada nori nenori butu data ir 
nereiketu nieko tikrint, nors gal ner ten tokio elemento...</EM></FONT></DIV>
<DIV><EM><FONT face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><STRONG><FONT face=Calibri>1. Taisykle Nr. 1 - Vartotoja nervina MsgBox 
pranesimai ir ju reikia vengti, geras stilius kada jie naudojasi is viso tik 
kritiniu atveju:</FONT></STRONG></EM></DIV>
<DIV><FONT size=2><EM><FONT color=#008080 
face=Calibri><STRONG></STRONG></FONT></EM></FONT>&nbsp;</DIV>
<DIV><FONT color=#808080 size=1 face=Calibri>&gt;&nbsp;&nbsp;&nbsp; If Nuo &gt; 
Iki Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Style = vbYes + 
vbCritical + vbDefaultButton2<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Title = "Negera data"<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Msg = 
"Jûs ávedëte klaidingà datà! Áveskite iðš 
naujo."<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response = MsgBox(Msg, 
Style, Title)<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit 
Sub<BR>&gt;&nbsp;&nbsp;&nbsp; End If</FONT></DIV>
<DIV>
<DIV><FONT size=2 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><EM>Paprasciausia suzinojus&nbsp;jei vartotojas datas 
suvede atbulai, kas is esmes yra JUSU problema, o ne vartotojo, tai programoje 
jas sukeisti vietomis:</EM></FONT></DIV>
<DIV><FONT size=2 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>If Me.DataNuo &gt; Me.DataIki 
Then</FONT></DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>&nbsp;&nbsp;&nbsp; Nuo = 
Me.DataIki</FONT></DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>&nbsp;&nbsp;&nbsp; Iki = 
Me.DataNuo</FONT></DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>Else</FONT></DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>&nbsp;&nbsp;&nbsp; Nuo 
=&nbsp;Me.DataNuo<BR>&nbsp;&nbsp;&nbsp; Iki = Me.DataIki</FONT></DIV>
<DIV><FONT color=#808080 size=2 face=Calibri>End If</FONT></DIV>
<DIV><FONT size=2 face=Calibri></FONT>&nbsp;</DIV></DIV>
<DIV><FONT color=#008080 size=2 face=Calibri><EM></EM></FONT>&nbsp;</DIV>
<DIV><EM><FONT face=Calibri><STRONG>2.</STRONG> Toliau <STRONG>jei visada 
dalyvauti turi data nuo ir iki</STRONG> tai galima su sql between komanda 
suktis</FONT></EM></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff><FONT face=Calibri>Where <FONT 
color=#ff00ff>data</FONT> <STRONG>between</STRONG> <FONT 
color=#ff00ff>nuo</FONT> and <FONT color=#ff00ff>iki</FONT></FONT></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><EM>Tada jusu VBA kodas atrodytu taip:</EM></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri>strfiltras = strfiltras &amp; "[dtmSiuntosData] BETWEEN 
'" &amp; Nuo &amp;"' And '" &amp; Iki &amp;"'"</FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><EM>Vietoj gigantisko:</EM></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT color=#808080 size=1 face=Calibri>&gt;&nbsp;&nbsp;&nbsp; strfiltras = 
strfiltras &amp; "[dtmSiuntosData] &gt;= '" &amp; Nuo &amp; "' And <BR>&gt; 
[dtmSiuntosData] &lt;= '" &amp; Iki &amp; "' And "<BR>&gt; ElseIf Not 
IsNull(Me.DataNuo) Then<BR>&gt;&nbsp;&nbsp;&nbsp; Nuo = 
Me.DataNuo<BR>&gt;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; 
"[dtmSiuntosData] &gt;= '" &amp; Nuo &amp; "' And "<BR>&gt; ElseIf Not 
IsNull(Me.DataIki) Then<BR>&gt;&nbsp;&nbsp;&nbsp; Iki = 
Me.DataIki<BR>&gt;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; 
"[dtmSiuntosData] &lt;= '" &amp; Iki &amp; "' And "</FONT></DIV><FONT size=2>
<DIV><FONT face=Arial></FONT><BR><FONT size=3 face=Calibri><EM>3. Kintamuju 
paspalvintu raudonai priskyrimas dubliuojasi:</EM></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><FONT color=#808080>&gt; If Not IsNull(Me.DataNuo) And 
Not IsNull(Me.DataIki) Then</FONT><BR><FONT color=#ff0000>&gt;&nbsp;&nbsp;&nbsp; 
Nuo = Me.DataNuo</FONT><BR><FONT color=#ff0000>&gt;&nbsp;&nbsp;&nbsp; Iki = 
Me.DataIki</FONT><BR><FONT color=#808080>&gt; <BR>&gt; '''''''Patikrina ar data 
teisinga<BR>&gt; <BR>&gt;&nbsp;&nbsp;&nbsp; If Nuo &gt; Iki 
Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Style = vbYes + 
vbCritical + vbDefaultButton2<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Title = "Negera data"<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Msg = 
"Jûs ávedëte klaidingà datà! Áveskite iðš 
naujo."<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response = MsgBox(Msg, 
Style, Title)<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit 
Sub<BR>&gt;&nbsp;&nbsp;&nbsp; End If<BR>&gt;&nbsp;&nbsp;&nbsp; strfiltras = 
strfiltras &amp; "[dtmSiuntosData] &gt;= '" &amp; Nuo &amp; "' And <BR>&gt; 
[dtmSiuntosData] &lt;= '" &amp; Iki &amp; "' And "<BR>&gt; ElseIf Not 
IsNull(Me.DataNuo) Then<BR></FONT><FONT color=#ff0000>&gt;&nbsp;&nbsp;&nbsp; Nuo 
= Me.DataNuo</FONT><BR><FONT color=#808080>&gt;&nbsp;&nbsp;&nbsp; strfiltras = 
strfiltras &amp; "[dtmSiuntosData] &gt;= '" &amp; Nuo &amp; "' And "<BR>&gt; 
ElseIf Not IsNull(Me.DataIki) Then<BR></FONT><FONT 
color=#ff0000>&gt;&nbsp;&nbsp;&nbsp; Iki = Me.DataIki</FONT><BR><FONT 
color=#808080>&gt;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; 
"[dtmSiuntosData] &lt;= '" &amp; Iki &amp; "' And "<BR>&gt; End 
If</FONT></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri><EM><STRONG>4. Option 
box'ai:</STRONG></EM></FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri><FONT color=#808080>&gt; ''''''Dar vienas Option group 
'Apmoketi_reisai'<BR>&gt;&nbsp; If Me.Apmoketi_reisai = 1 
Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; "[SaskID] is 
not Null AND "<BR>&gt;&nbsp; ElseIf Me.Apmoketi_reisai = 2 
Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; "[SaskID] is 
Null AND "<BR>&gt;&nbsp; End If</FONT><BR></FONT></DIV>
<DIV><EM><FONT size=3 face=Calibri><STRONG>Blogai!</STRONG> Kas? o tas kad i sql 
uzklausa pridedama pvz. <STRONG>"[SaskID] is Null <FONT color=#ff0000 
size=5>AND</FONT> "</STRONG> <FONT color=#ff0000>visiskai neziurint ar toliau 
bus dar kazkas salygoje ar ne!</FONT></FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri>Jeigu jau taip formuojate uzklausa kaip 
string tai visada geriausia daryti taip:</FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT face=Calibri><FONT size=3>Apsirasau savo: <STRONG>Select * From 
lentele </STRONG></FONT></FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri>Tada dedu&nbsp;tokia salyga kuri visada bus 
(is bedos jei tokios nera rasau <STRONG>WHERE 1=1</STRONG>, o prie jos tada jau 
AND ... AND ... AND , pvz data:</FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri><STRONG>Where data between nuo and 
Iki</STRONG></FONT></EM></DIV>
<DIV><STRONG><EM><FONT size=3 face=Calibri></FONT></EM></STRONG>&nbsp;</DIV>
<DIV><FONT face=Calibri><FONT size=3><EM>O tada kadangi as zinau kad jau viena 
salyga yra, galiu dadejinet drasiai salygas su <STRONG>AND</STRONG> ar 
<STRONG>OR</STRONG> operatorium atitinkamai rasant visada rasau ne gale o 
priekyje jungiklu AND|OR: </EM><EM><STRONG>" AND</STRONG>&nbsp; laukas = kazkam" 
ir niekada nedaryti atbulai pvz.: " laukas=kazkam AND" <FONT color=#ff0000>&lt; 
-- nes gal formuojant uzklausa paaiskes kad tolimesniu salygu nera</FONT>. Ir 
dar...&nbsp;visada reikia deti pridedant stringa pries AND tarpa (tiesiog 
issiugdyti iproti).</EM></FONT></FONT></DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri>Gaila access po ranka nera&nbsp;(pas mane 
openoffice) kad paziureti bet jei tai kazkoks checkboxas,radioboxas ar jis 
neturi boolean propety Checked?</FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri>If ChkPozymis.Chedked&nbsp;= True Then 
</FONT></DIV>
<DIV><FONT size=3 face=Calibri>&nbsp;&nbsp;&nbsp; str =&nbsp;str&nbsp;&amp; " 
AND Kazkas Is Null"</FONT></DIV>
<DIV><FONT size=3 face=Calibri>End if</FONT></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri>Arba:</FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri>str = str &amp; IIF(ChkPozymis.Checked:" AND 
Kazkas Is Null":"")</FONT></DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri><EM>Ka daro funkcija IIF - supaprastina koda, bet 
atsargiai tik su reiksmem kurios gali buti null nes mes 
klaidas:</EM></FONT></DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri>IIF ( Salyga : Teigiamas rezultatas : Neigiamas 
rezultatas )</FONT></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri><EM>IIF grazina teigiama arba neigiama rezultata 
priklausomai nuo salygos, pvz:</EM></FONT></DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri>MsgBox 
IIF(metai&gt;17:"Suauges":"Nepilnametis)</FONT></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><EM><FONT size=3 face=Calibri>Bet luzines jei metai gali buti 
Null...</FONT></EM></DIV>
<DIV><EM><FONT size=3 face=Calibri></FONT></EM><EM><FONT size=3 
face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT size=3 face=Calibri>Sekmes darbuose :)</FONT></DIV>
<DIV><FONT size=3 face=Calibri>JDM.</FONT></DIV>
<DIV><FONT size=3 face=Calibri>Freelancer Developer</FONT></DIV>
<DIV><FONT color=#008080 face=Calibri><A 
href="http://www.lythum.lt">http://www.lythum.lt</A></FONT></DIV>
<DIV><EM><FONT color=#008080 face=Calibri></FONT></EM>&nbsp;</DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=Calibri>&gt; 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>&gt; 
'''''''''Pirmas option group 'IMSiuntos'<BR>&gt; <BR>&gt;&nbsp; If Me.IMSiuntos 
= 1 Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = strfiltras &amp; 
"([VaztarTipas] = 'P' OR [VaztarTipas] = <BR>&gt; 'PF') And "<BR>&gt; End 
If<BR>&gt; 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>&gt; 
''''text box 'SandelioNr', kuri as uzpildau atidarant forma,<BR>&gt; 
<BR>&gt;&nbsp; If Me.SandelioNr = 1 Then<BR>&gt;&nbsp; strfiltras = strfiltras 
&amp; "(SandNr = 1) AND "<BR>&gt;&nbsp;&nbsp; ElseIf SandelioNr = 2 Then 
strfiltras = strfiltras &amp; "(SandNr = 2) AND "<BR>&gt;&nbsp; End If<BR>&gt; 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>&gt;&nbsp;'''''''&nbsp; 
ComboBox'ai, pagal kuriuos filtruojami duomenys<BR>&gt; <BR>&gt;&nbsp; If Not 
IsNull(Me.Siunta) Then strfiltras = strfiltras &amp; "[strSiuntosNr] = <BR>&gt; 
'" &amp; Me.Siunta &amp; "' AND "<BR>&gt;&nbsp; If Not IsNull(Me.Klientas) Then 
strfiltras = strfiltras &amp; "[strKlientas] = <BR>&gt; '" &amp; Me.Klientas 
&amp; "' AND "<BR>&gt;&nbsp; If Not IsNull(Me.SaskMoketojas) Then strfiltras = 
strfiltras &amp; <BR>&gt; "[strSaskMoketojas] = '" &amp; Me.SaskMoketojas &amp; 
"' AND "<BR>&gt;&nbsp; If Not IsNull(Me.Tipas) Then strfiltras = strfiltras 
&amp; "[VaztarTipas] = '" <BR>&gt; &amp; Me.Tipas &amp; "' AND "<BR>&gt;&nbsp; 
If Not IsNull(Me.SalisFrom) Then strfiltras = strfiltras &amp; <BR>&gt; 
"[strSalis_from] = '" &amp; Me.SalisFrom &amp; "' AND "<BR>&gt;&nbsp; If Not 
IsNull(Me.SalisTo) Then strfiltras = strfiltras &amp; "[strSalis_to] = <BR>&gt; 
'" &amp; Me.SalisTo &amp; "' AND "<BR>&gt;&nbsp; If Not IsNull(Me.Tr_priem) Then 
strfiltras = strfiltras &amp; "[strTrPriemNr] <BR>&gt; = '" &amp; Me.Tr_priem 
&amp; "' AND "<BR>&gt;&nbsp; If Not IsNull(Me.Statusas) Then strfiltras = 
strfiltras &amp; "[MuitStatusas] <BR>&gt; = '" &amp; Me.Statusas &amp; "' AND 
"<BR>&gt;&nbsp; If Not IsNull(Me.KortelesNr) Then strfiltras = strfiltras &amp; 
<BR>&gt; "[strKortelesNr] = '" &amp; Me.KortelesNr &amp; "' AND "<BR>&gt; 
<BR>&gt; 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>&gt; 
''''''Dar vienas Option group 'Apmoketi_reisai'<BR>&gt;&nbsp; If 
Me.Apmoketi_reisai = 1 Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = 
strfiltras &amp; "[SaskID] is not Null AND "<BR>&gt;&nbsp; ElseIf 
Me.Apmoketi_reisai = 2 Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = 
strfiltras &amp; "[SaskID] is Null AND "<BR>&gt;&nbsp; End If<BR>&gt; <BR>&gt; 
<BR>&gt; <BR>&gt;&nbsp; If Not IsNull(strfiltras) And (Len(strfiltras) &gt; 0) 
Then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strfiltras = Mid(strfiltras, 1, 
Len(strfiltras) - 5)<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.Filter = 
strfiltras<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.FilterOn = 
True<BR>&gt;&nbsp; Else<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.FilterOn = 
False<BR>&gt;&nbsp; End If<BR>&gt; Me.OrderBy = "dtmSiuntosData desc"<BR>&gt; 
Me.OrderByOn = True<BR>&gt;&nbsp; Exit Sub<BR>&gt; 
ErrH:<BR>&gt;&nbsp;&nbsp;&nbsp; MsgBox Err.Description<BR>&gt; End Sub<BR>&gt; 
<BR>&gt; <BR>&gt; "Laimis" &lt;</FONT></FONT><A 
href="mailto:wiela@centras.lt"><FONT size=2 
face=Calibri>wiela@centras.lt</FONT></A><FONT size=2 face=Calibri>&gt; wrote in 
message <BR>&gt; </FONT><A href="news:hkhigu$i6s$1@trimpas.omnitel.net"><FONT 
size=2 face=Calibri>news:hkhigu$i6s$1@trimpas.omnitel.net</FONT></A><FONT size=2 
face=Calibri>...<BR>&gt;&gt; Vaida rašė:<BR>&gt;&gt;&gt; Nu 
gerai,<BR>&gt;&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;&gt; (varda, pavarde). Bet as dar 
noriu atsirinkti mokinius kuriu gimimo<BR>&gt;&gt;&gt; diena yra : sausio - 
balandzio, geguzes - rugpjucio, rugsejo - gruodzio<BR>&gt;&gt;&gt; menesiais. 
Taigi, as pasidarau option group su tokiais punktais:<BR>&gt;&gt;<BR>&gt;&gt; 
Pasidaryti tai pasidarai, o *kaip* pasidarai...?<BR>&gt;&gt; Arba įmesk į 
o.binaries pavydį, pačią programą (db nebūtina), arba beveik <BR>&gt;&gt; 
garantuotai nieko nebus...<BR>&gt;&gt;</FONT></DIV></BODY></HTML>