Bosna i Hercegovina



#16 23.01.2015-13:48
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Samo još kada bi mi prikazivao umjesto šifre opštine naziv bilo bi mi mnogo bolje. Zbog čega kada pokrenem formu frmStanjeZFilt (tu mi izlista stanje) pa kada idem na filter pokrenem formu frmStanjeZFilt_QBF ta forma ondosno filter ne radi?
Pozdrav!
↑  ↓

#17 23.01.2015-14:22
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Baza za evidenciju korisnika
Citat od Dado:
Samo još kada bi mi prikazivao umjesto šifre opštine naziv bilo bi mi mnogo bolje.
U Query qryPretrazivanjeAsc dodaj T_Opstine i kolonu Opština preptavi Opština: Naziiv_Opstine (kao na priloženoj slici)
Citat od Dado:
Zbog čega kada pokrenem formu frmStanjeZFilt (tu mi izlista stanje) pa kada idem na filter pokrenem formu frmStanjeZFilt_QBF ta forma ondosno filter ne radi?
U frmStanjeZFilt_QBF nisi odabrao Record Source pa je zato foema prazna. Odakle ta forma uzima podatke?
Također na formi frmStanjeZFilt, ispod dugmeta Filter ti je kod:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmStanjeZFilt_QBF"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Nisi stavio vrijednost za stLinkCriteria, a tu bi trebalo ići nešto kao

stLinkCriteria = "[JMBGKorisnika]=" & " ' " & Me![JMBGKorisnika] & " ' "

To ovisi na temelju koje vrijednosti filtriraš.

Još jedna sugestija. Kod naziva tablica i elemenata tablica izbjegavaj slova č,đ,ž. itd. jer ti to može praviti probleme kod pisanja Koda.
Također izbjegavaj odvojene riječi kao npr. Broj telefona. Bolje je napisati BrojTelefona ili Broj_telefona

Ikona prilozene slike:
Image1.jpg
Tip fajla: Informacije o fajlu: jpg jpg
Preuzimanja: 34
Veličina: 61.76 KB
Veličina slike: 518 x 557 Pixels


Pozdrav
↑  ↓

#18 23.01.2015-14:33
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Evo sada radi pretraga i za opštine.
Znaci li ti sta sljedece:
Function glrQBF_DoHide(frm As Form)
Dim varSQL As Variant
Dim strParentForm As String

'Get the name of the Parent form
strParentForm = Left(CStr(frm.Name), Len(CStr(frm.Name)) - 4)
'Create the approprite Where clause based on the fields with data in them
varSQL = glrDoQBF(CStr(frm.Name), False)
'Open the Parent form filtered with the Where clause genereated above
DoCmd.OpenForm strParentForm, acNormal, , varSQL
'Make this *_QBF form invisible
frm.Visible = False

End Function
Pozdrav!
↑  ↓

#19 23.01.2015-14:34
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
To sam nasao kod jedne baze za ovu formu pa sam to pokusao iskoristiti i ovdje ali mi ne polazi za rukom.
Pozdrav!
↑  ↓

#20 23.01.2015-14:44
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Baza za evidenciju korisnika
Pa reci koje podatke želiš filtrirati i to se onda može i drugačije napraviti.
Pozdrav
↑  ↓

#21 23.01.2015-21:31
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Pau ovoj bazi u kojoj mi ova forma frmStanjeZFilt_QBF radi svi podaci se mogu filtrirati.
Pozdrav!
↑  ↓

#22 24.01.2015-09:05
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Baza za evidenciju korisnika
Nejasan si. Što znači "svi se podaci mogu filtrirati"? Podaci bi se trebali filtrirati po nekom kriteriju, npr:
-prikaži mi sve iz nekog mjesta
-prikaži mi sve iz neke općine
-prikaži mi sve koji su dobili određenu pomoć
itd.
To sve možeš dobiti sa formom frmPretraživanje koju sam stavio u primjeru.

A što bi Funkcija koju si stavio u prethodnom postu trebala raditi ja baš nisam siguran
Pozdrav
↑  ↓

#23 24.01.2015-13:35
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Baza za evidenciju korisnika
Evo je

DownloadIzvorni kod (vb.net):
  1. Function glrDoQBF(strFormName As String, fCloseIt As Integer)
  2.    
  3.     ' Load the specified form as a QBF form.  If
  4.     ' the form is still loaded when control returns
  5.     ' to this function, then it will attempt to
  6.     ' build an SQL WHERE clause describing the
  7.     ' values in the fields.  DoQBF() will return
  8.     ' either that SQL string or a null string,
  9.     ' depending on what the user chose to do and
  10.     ' whether or not any fields were filled in.
  11.  
  12.     ' In:
  13.     '     strFormName: Name of the form to load
  14.     '     fCloseIt: Close the form, if the user didn't?
  15.     ' Out:
  16.     '     Return Value: The calculated SQL string.
  17.    
  18.     Dim strSQL As String
  19.  
  20.     DoCmd.OpenForm strFormName, WindowMode:=acDialog
  21.  
  22.     ' You won't get here until user hides or closes the form.
  23.     ' If the user closed the form, there's nothing
  24.     ' to be done.  Otherwise, build up the SQL WHERE
  25.     ' clause.  Once you're done, if the caller requested
  26.     ' the QBF form to be closed, close it now.
  27.     If isFormLoaded(strFormName) Then
  28.         strSQL = BuildWHEREClause(Forms(strFormName))
  29.         If fCloseIt Then
  30.             DoCmd.Close acForm, strFormName
  31.         End If
  32.     End If
  33.     glrDoQBF = strSQL
  34. End Function

Pozdrav
↑  ↓

#24 26.01.2015-09:13
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Evo citava procedura koja radi u jednoj drugoj bazi

ption Compare Database 'Use database order for string comparisons
Option Explicit

Const QUOTE = """"

Private Function BuildSQLString(strFieldName As String, varFieldValue As Variant, intFieldType As Integer)

' Build string that can be used as part of an
' SQL WHERE clause. This function looks at
' the field type for the specified table field,
' and constructs the expression accordingly.

Dim strTemp As String

strTemp = "[" & strFieldName & "]"
' If the first part of the value indicates that it's
' to be left as is, leave it alone. Otherwise,
' munge the value as necessary.
If isOperator(varFieldValue) Then
strTemp = strTemp & " " & varFieldValue
Else
Select Case intFieldType
Case dbBoolean
' Convert to TRUE/FALSE
strTemp = strTemp & " = " & CInt(varFieldValue)
Case dbText, dbMemo
' Assume we're looking for anything that STARTS with the text we got.
' This is probably a LOT slower. If you want direct matches
' instead, use the commented-out line.
' strTemp = strTemp & " = " & QUOTE & varFieldValue & QUOTE
strTemp = strTemp & " LIKE " & QUOTE & varFieldValue & "*" & QUOTE
Case dbByte, dbInteger, dbLong, dbCurrency, dbSingle, dbDouble
' Convert to straight numeric representation.
strTemp = strTemp & " = " & varFieldValue
Case dbDate
' Convert to #date# format.
strTemp = strTemp & " = " & "#" & varFieldValue & "#"
Case Else
' This function really can't handle any of the other data types (DB_BINARY?)
strTemp = ""
End Select
End If
BuildSQLString = strTemp
End Function

Private Function BuildWHEREClause(frm As Form) As String

' Build the full WHERE clause based on fields
' on the passed-in form. This function attempts
' to look at all controls that have the correct
' settings in the Tag properties.

Dim intI As Integer
Dim strLocalSQL As String
Dim strTemp As String
Dim varDataType As Integer

Dim varControlSource As Variant
Dim ctl As Control

For intI = 0 To frm.Count - 1
Set ctl = frm(intI)
' Get the original control source.
varControlSource = adhCtlTagGetItem(ctl, "qbfField")
If Not IsNull(varControlSource) Then
' If the value of the control isn't null...
If Not IsNull(ctl) Then
' then get the value.
varDataType = adhCtlTagGetItem(ctl, "qbfType")
If Not IsNull(varDataType) Then
strTemp = "(" & BuildSQLString(CStr(varControlSource), ctl, CInt(varDataType)) & ")"
strLocalSQL = strLocalSQL & IIf(Len(strLocalSQL) = 0, strTemp, " AND " & strTemp)
End If
End If
On Error GoTo 0
End If
Next intI
If Len(strLocalSQL) > 0 Then strLocalSQL = "(" & strLocalSQL & ")"
BuildWHEREClause = strLocalSQL
End Function

Function glrDoQBF(strFormName As String, fCloseIt As Integer)

' Load the specified form as a QBF form. If
' the form is still loaded when control returns
' to this function, then it will attempt to
' build an SQL WHERE clause describing the
' values in the fields. DoQBF() will return
' either that SQL string or a null string,
' depending on what the user chose to do and
' whether or not any fields were filled in.

' In:
' strFormName: Name of the form to load
' fCloseIt: Close the form, if the user didn't?
' Out:
' Return Value: The calculated SQL string.

Dim strSQL As String

DoCmd.OpenForm strFormName, WindowMode:=acDialog

' You won't get here until user hides or closes the form.
' If the user closed the form, there's nothing
' to be done. Otherwise, build up the SQL WHERE
' clause. Once you're done, if the caller requested
' the QBF form to be closed, close it now.
If isFormLoaded(strFormName) Then
strSQL = BuildWHEREClause(Forms(strFormName))
If fCloseIt Then
DoCmd.Close acForm, strFormName
End If
End If
glrDoQBF = strSQL
End Function

Function glrQBF_DoClose()

' Close the current form.

DoCmd.Close
End Function

Function glrQBF_DoHide(frm As Form)
Dim varSQL As Variant
Dim strParentForm As String

'Get the name of the Parent form
strParentForm = Left(CStr(frm.Name), Len(CStr(frm.Name)) - 4)
'Create the approprite Where clause based on the fields with data in them
varSQL = glrDoQBF(CStr(frm.Name), False)
'Open the Parent form filtered with the Where clause genereated above
DoCmd.OpenForm strParentForm, acNormal, , varSQL
'Make this *_QBF form invisible
frm.Visible = False

End Function

Private Function isFormLoaded(strName As String)

' Return a logical value indicating whether a
' given formname is loaded or not.
On Error Resume Next
isFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strName) <> 0)
If Err.Number <> 0 Then
isFormLoaded = False
End If
End Function

Private Function isOperator(varValue As Variant)

' Return a logical value indicating whether a
' value passed in is an operator or not.
' This is NOT infallible, and may need correcting.

Dim varTemp As Variant

varTemp = Trim(UCase(varValue))
isOperator = False

' Check first character for <,>, or =
If InStr("<>=", Left(varTemp, 1)) > 0 Then
isOperator = True
' Check for IN (x,y,z)
ElseIf ((Left(varTemp, 4) = "IN (") And (Right(varTemp, 1) = ")")) Then
isOperator = True
' Check for BETWEEN ... AND ...
ElseIf ((Left(varTemp, Innocent = "BETWEEN ") And (InStr(varTemp, " AND ") > 0)) Then
isOperator = True
' Check for NOT xxx
ElseIf (Left(varTemp, 4) = "NOT ") Then
isOperator = True
' Check for LIKE xxx
ElseIf (Left(varTemp, 5) = "LIKE ") Then
isOperator = True
End If
End Function
Pozdrav!
↑  ↓

#25 26.01.2015-09:20
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Ove dvije forme frmStanjeZFilt i frmStanjeZFilt_QBF su mi vazne jer imam filter, karticu korisnika i export u excel. Sve na jednom jestu, ali samo mi nije jasno zbog cega ovaj filter frmStanjeZFilt_QBF ne radi.
Pozdrav!
↑  ↓

#26 26.01.2015-10:26
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Ocjena: Ocjena:100 Subject: Re: Baza za evidenciju korisnika
O kojem filteru ti stalno govoriš. To što ti ovo radi u nekoj drugoj bazi ne znači da će sve isto raditi i u ovom tvom primjeru.
Dali je tebi uopće jasno kako procedure rade. Ti na formi frmStanjeZFilt ispod dugmeta koje se zove Filter imaš kod:

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmStanjeZFilt_QBF"
DoCmd.OpenForm stDocName, , , stLinkCriteria

taj kod nne radi ništa drugo nego otavra formu "frmStanjeZFilt_QBF"

Ispod dugmeta za eksport u excel imaš

directory = getpath(DB.Name)

Gdje ti je Funkcija getpath koja se ovdje poziva.

Stavi za primjer tu bazu gdje to sve radi pa da vidimo.
Pozdrav
↑  ↓

#27 26.01.2015-11:03
Dado Offline
Clan
Registrovan/a od: 27.10.2011-19:26
Komentari: 255


Subject: Re: Baza za evidenciju korisnika
Možeš li mi napraviti kod da exportujem podatke u excel iz listboxa List30 koji je smješten u formi frmPretrazivanje, i da kada selektujem nekog korisnika na listboxu List30 klikom na dugme otvorim njegovu karticu pomoci i otprintam je. Ja bih pripremio reports.
Pozdrav!
↑  ↓

#28 26.01.2015-13:05
pmiroslav Offline
Moderator
Registrovan/a od: 02.02.2009-10:32
Komentari: 1,339


Subject: Re: Baza za evidenciju korisnika
Citat od Dado:
i da kada selektujem nekog korisnika na listboxu List30 klikom na dugme otvorim njegovu karticu pomoci i otprintam je. Ja bih pripremio reports.
To već imaš. Selektiraj korisnika i pritisni dugme PRIKAŽI KORISNIKA.

Za export u excel na formi za pretraživanje napravi dugme koje ćeš nazvati cmdExportToExcel i ispod njega kopiraj slijedeći kod
DownloadIzvorni kod (vb.net):
  1. Private Sub cmdExportToExcel_Click()
  2. On Error GoTo ErrorHandler
  3.  
  4. Dim strTable As String
  5. Dim strWorksheetPath As String
  6.  
  7. strWorksheetPath = "C:\Korisnici\"  'Ovdje napiši gdje da se sprema Excell datoteka
  8. strWorksheetPath = strWorksheetPath & "korisnici.xls"
  9. strTable = "qryPretrazivanjeAsc"
  10. DoCmd.TransferSpreadsheet transfertype:=acExport, _
  11. spreadsheettype:=acSpreadsheetTypeExcel9, _
  12. TableName:=strTable, _
  13. filename:=strWorksheetPath, _
  14. HasFieldNames:=True
  15.  
  16. ErrorHandlerExit:
  17. Exit Sub
  18. ErrorHandler:
  19. MsgBox "Greška br: " & Err.Number _
  20. & "; Opis: " & Err.Description
  21. Resume ErrorHandlerExit
  22.  
  23. End Sub

Pozdrav
↑  ↓

Stranice (2): 1, 2


All times are GMT +01:00. Current time: 12.12.2017-22:47.