Program Data VBA
Program Data VBA
Call UpdateData
Call Reset
End Sub
Dim i As VbMsgBoxResult
If Selected_List() = 0 Then
Exit Sub
End If
i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Potvrdi")
ThisWorkbook.Sheets("Database").Rows(Selected_List() + 1).Delete
Call Reset
End Sub
If Selected_List() = 0 Then
MsgBox "Nije selektovan red", vbOKOnly + vbInformation, "Edit"
Exit Sub
End If
Call SetEditData
MsgBox "Molim vas uradite izmene i zatim kliknite na 'Update' dugme kako biste sačuvali izmenu",
vbOKOnly + vbInformation, "Edit"
End Sub
Call Reset
End Sub
Call Reset
End Sub
Call UpdateData
Call Reset
End Sub
End Sub
Call Reset
End Sub
Sub Reset()
iRow = ThisWorkbook.Sheets("Database").Cells(ThisWorkbook.Sheets("Database").Rows.Count,
1).End(xlUp).Row + 1 ' Identifikacija poslednjeg reda
With frmForm
.txtID.Value = ""
.txtImep.Value = ""
.optTeret.Value = False
.optPutnik.Value = False
.cmbSeminar.Clear
.txtRowNumber.Value = ""
.txtTelefon.Value = ""
.txtMesto.Value = ""
.lstDatabase.ColumnHeads = True
Else
.lstDatabase.RowSource = "Database!A2:K2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
Else
iRow = frmForm.txtRowNumber.Value
End If
jmbg = frmForm.txtID.Value
' JMBG već postoji, ažuriramo samo datum seminara i ostavljamo postojeće datume netaknutim
seminar = frmForm.cmbSeminar.Value
End If
Exit Sub
End If
Next iRow
With sh
.Cells(iRow, 2) = frmForm.txtImep.Value
.Cells(iRow, 3) = jmbg
.Cells(iRow, 4) = frmForm.txtMesto.Value
.Cells(iRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Sub SetEditData()
With frmForm
.txtRowNumber.Value = Selected_List() + 1
.txtID.Value = .lstDatabase.List(.lstDatabase.ListIndex, 2)
.txtImep.Value = .lstDatabase.List(.lstDatabase.ListIndex, 1)
sTransport = .lstDatabase.List(.lstDatabase.ListIndex, 4)
.optTeret.Value = True
Else
.optPutnik.Value = True
End If
.cmbSeminar.Value = .lstDatabase.List(.lstDatabase.ListIndex, 6)
.txtTelefon.Value = .lstDatabase.List(.lstDatabase.ListIndex, 5)
.txtMesto.Value = .lstDatabase.List(.lstDatabase.ListIndex, 3)
.txtDatumispisa.Value = .lstDatabase.List(.lstDatabase.ListIndex, 7)
End With
End Sub
Sub UpdateData()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
selectedRow = frmForm.txtRowNumber.Value
With sh
MsgBox "Selected row is empty. Cannot update.", vbOKOnly + vbExclamation, "Update Error"
Exit Sub
End If
.Cells(selectedRow, 2) = frmForm.txtImep.Value
.Cells(selectedRow, 3) = frmForm.txtID.Value
.Cells(selectedRow, 4) = frmForm.txtMesto.Value
.Cells(selectedRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Dim i As Long
Selected_List = 0
For i = 0 To frmForm.lstDatabase.ListCount - 1
If frmForm.lstDatabase.Selected(i) = True Then
Selected_List = i + 1
Exit For
End If
Next i
End Function
Option Explicit
Sub Reset()
iRow = ThisWorkbook.Sheets("Database").Cells(ThisWorkbook.Sheets("Database").Rows.Count,
1).End(xlUp).Row + 1 ' Identifikacija poslednjeg reda
With frmForm
.txtID.Value = ""
.txtImep.Value = ""
.optTeret.Value = False
.optPutnik.Value = False
.cmbSeminar.Clear
.txtRowNumber.Value = ""
.txtTelefon.Value = ""
.txtMesto.Value = ""
.lstDatabase.ColumnHeads = True
Else
.lstDatabase.RowSource = "Database!A2:K2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
Else
iRow = frmForm.txtRowNumber.Value
End If
jmbg = frmForm.txtID.Value
' JMBG već postoji, ažuriramo samo datum seminara i ostavljamo postojeće datume netaknutim
seminar = frmForm.cmbSeminar.Value
End If
Exit Sub
End If
Next iRow
With sh
.Cells(iRow, 2) = frmForm.txtImep.Value
.Cells(iRow, 3) = jmbg
.Cells(iRow, 4) = frmForm.txtMesto.Value
.Cells(iRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Sub SetEditData()
With frmForm
.txtRowNumber.Value = Selected_List() + 1
.txtID.Value = .lstDatabase.List(.lstDatabase.ListIndex, 2)
.txtImep.Value = .lstDatabase.List(.lstDatabase.ListIndex, 1)
sTransport = .lstDatabase.List(.lstDatabase.ListIndex, 4)
.optTeret.Value = True
Else
.optPutnik.Value = True
End If
.cmbSeminar.Value = .lstDatabase.List(.lstDatabase.ListIndex, 6)
.txtTelefon.Value = .lstDatabase.List(.lstDatabase.ListIndex, 5)
.txtMesto.Value = .lstDatabase.List(.lstDatabase.ListIndex, 3)
End With
End Sub
Sub UpdateData()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
selectedRow = frmForm.txtRowNumber.Value
With sh
MsgBox "Selected row is empty. Cannot update.", vbOKOnly + vbExclamation, "Update Error"
Exit Sub
End If
.Cells(selectedRow, 2) = frmForm.txtImep.Value
.Cells(selectedRow, 3) = frmForm.txtID.Value
.Cells(selectedRow, 4) = frmForm.txtMesto.Value
.Cells(selectedRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Function Selected_List() As Long
Dim i As Long
Selected_List = 0
For i = 0 To frmForm.lstDatabase.ListCount - 1
Selected_List = i + 1
Exit For
End If
Next i
End Function
' Dugme za ažuriranje podataka
Call UpdateData
Call Reset
End Sub
Dim i As VbMsgBoxResult
If Selected_List() = 0 Then
Exit Sub
End If
i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Potvrdi")
ThisWorkbook.Sheets("Database").Rows(Selected_List() + 1).Delete
Call Reset
End Sub
If Selected_List() = 0 Then
MsgBox "Nije selektovan red", vbOKOnly + vbInformation, "Edit"
Exit Sub
End If
Call SetEditData
MsgBox "Molim vas uradite izmene i zatim kliknite na 'Update' dugme kako biste sačuvali izmenu",
vbOKOnly + vbInformation, "Edit"
End Sub
Call Reset
End Sub
Call Reset
End Sub
Call UpdateData
Call Reset
End Sub
End Sub
Call Reset
End Sub
Sub Reset()
iRow = ThisWorkbook.Sheets("Database").Cells(ThisWorkbook.Sheets("Database").Rows.Count,
1).End(xlUp).Row + 1 ' Identifikacija poslednjeg reda
With frmForm
.txtID.Value = ""
.txtImep.Value = ""
.optTeret.Value = False
.optPutnik.Value = False
.cmbSeminar.Clear
.txtRowNumber.Value = ""
.txtTelefon.Value = ""
.txtMesto.Value = ""
.lstDatabase.ColumnHeads = True
Else
.lstDatabase.RowSource = "Database!A2:K2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
Else
iRow = frmForm.txtRowNumber.Value
End If
jmbg = frmForm.txtID.Value
' JMBG već postoji, ažuriramo samo datum seminara i ostavljamo postojeće datume netaknutim
seminar = frmForm.cmbSeminar.Value
End If
Exit Sub
End If
Next iRow
With sh
.Cells(iRow, 2) = frmForm.txtImep.Value
.Cells(iRow, 3) = jmbg
.Cells(iRow, 4) = frmForm.txtMesto.Value
.Cells(iRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Sub SetEditData()
With frmForm
.txtRowNumber.Value = Selected_List() + 1
.txtID.Value = .lstDatabase.List(.lstDatabase.ListIndex, 2)
.txtImep.Value = .lstDatabase.List(.lstDatabase.ListIndex, 1)
sTransport = .lstDatabase.List(.lstDatabase.ListIndex, 4)
.optTeret.Value = True
Else
.optPutnik.Value = True
End If
.cmbSeminar.Value = .lstDatabase.List(.lstDatabase.ListIndex, 6)
.txtTelefon.Value = .lstDatabase.List(.lstDatabase.ListIndex, 5)
.txtMesto.Value = .lstDatabase.List(.lstDatabase.ListIndex, 3)
.txtDatumispisa.Value = .lstDatabase.List(.lstDatabase.ListIndex, 7)
End With
End Sub
Sub UpdateData()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Database")
selectedRow = frmForm.txtRowNumber.Value
With sh
MsgBox "Selected row is empty. Cannot update.", vbOKOnly + vbExclamation, "Update Error"
Exit Sub
End If
.Cells(selectedRow, 2) = frmForm.txtImep.Value
.Cells(selectedRow, 3) = frmForm.txtID.Value
.Cells(selectedRow, 4) = frmForm.txtMesto.Value
.Cells(selectedRow, 6) = frmForm.txtTelefon.Value
seminar = frmForm.cmbSeminar.Value
End If
End With
End Sub
Dim i As Long
Selected_List = 0
For i = 0 To frmForm.lstDatabase.ListCount - 1
If frmForm.lstDatabase.Selected(i) = True Then
Selected_List = i + 1
Exit For
End If
Next i
End Function
' Dugme za ažuriranje podataka Private Sub cmbUpdate_Click() Call UpdateData Call Reset
MsgBox "Izmenjeni podaci su sacuvani.", vbOKOnly + vbInformation, "Updated" End Sub '
Dugme za brisanje Private Sub cmdDelete_Click() Dim i As VbMsgBoxResult If Selected_List() = 0
Then MsgBox "Nije izabran nijedan red.", vbOKOnly + vbInformation, "Delete" Exit Sub End If i =
MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Potvrdi") If i =
vbNo Then Exit Sub ThisWorkbook.Sheets("Database").Rows(Selected_List() + 1).Delete Call
Reset MsgBox "Selektovan red je obrisan.", vbOKOnly + vbInformation, "Deleted" End Sub '
Dugme za edit Private Sub cmdEdit_Click() If Selected_List() = 0 Then MsgBox "Nije selektovan
red", vbOKOnly + vbInformation, "Edit" Exit Sub End If ' Postavljanje vrednosti za izmenu Call
SetEditData MsgBox "Molim vas uradite izmene i zatim kliknite na 'Update' dugme kako biste
sa?uvali izmenu", vbOKOnly + vbInformation, "Edit" End Sub ' Dugme za resetovanje polja
Private Sub cmdReset_Click() Dim msgValue As VbMsgBoxResult msgValue = MsgBox("Da li
želite resetovati polja?", vbYesNo + vbInformation, "Potvrdite") If msgValue = vbNo Then Exit
Sub Call Reset End Sub ' Dugme za ?uvanje podataka Private Sub cmdSave_Click() Dim msgValue
As VbMsgBoxResult msgValue = MsgBox("Da li želite sacuvati podatke?", vbYesNo +
vbInformation, "Potvrdite") If msgValue = vbNo Then Exit Sub Call Submit Call Reset End Sub '
Dugme za ažuriranje podataka Private Sub cmdUpdate_Click() Call UpdateData Call Reset
MsgBox "Izmenjeni podaci su sa?uvani.", vbOKOnly + vbInformation, "Updated" End Sub Private
Sub Label10_Click() End Sub ' Inicijalizacija forme Private Sub UserForm_Initialize() Call Reset End
Sub Sub Reset() Dim iRow As Long iRow =
ThisWorkbook.Sheets("Database").Cells(ThisWorkbook.Sheets("Database").Rows.Count,
1).End(xlUp).Row + 1 ' Identifikacija poslednjeg reda With frmForm .txtID.Value =
"" .txtImep.Value = "" .optTeret.Value = False .optPutnik.Value =
False .cmbSeminar.Clear .cmbSeminar.AddItem "Seminar 1" .cmbSeminar.AddItem "Seminar
2" .cmbSeminar.AddItem "Seminar 3" .cmbSeminar.AddItem "Seminar 4" .cmbSeminar.AddItem
"Seminar 5" .txtRowNumber.Value = "" .txtTelefon.Value = "" .txtMesto.Value = "" .txtOca.Value =
"" .lstDatabase.ColumnCount = 12 ' Dodajte jedan za "Redni broj" .lstDatabase.ColumnHeads =
True .lstDatabase.ColumnWidths = "20,100,70,60,50,60,50,50,50,50,50,50" ' Prilagodite širine
kolona If iRow > 1 Then .lstDatabase.RowSource = "Database!A2:L" & iRow
Else .lstDatabase.RowSource = "Database!A2:L2" End If End With End Sub Sub Submit() Dim sh
As Worksheet Dim iRow As Long Dim seminar As String Dim jmbg As String Set sh =
ThisWorkbook.Sheets("Database") If frmForm.txtRowNumber.Value = "" Then iRow =
sh.Cells(sh.Rows.Count, 1).End(xlUp).Row + 1 Else iRow = frmForm.txtRowNumber.Value End If
jmbg = frmForm.txtID.Value ' Provera da li JMBG ve? postoji u spisku For iRow = 2 To
sh.Cells(sh.Rows.Count, 3).End(xlUp).Row If sh.Cells(iRow, 3).Value = jmbg Then ' JMBG ve?
postoji, ažuriramo samo datum seminara i ostavljamo postoje?e datume netaknutim seminar =
frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then ' IZMENA: Promenite datum na
vrednost iz txtDatumIspisa sh.Cells(iRow, 7) = Format(DateValue(frmForm.txtDatumispisa.Value),
"DD.MM.YYYY") ElseIf seminar = "Seminar 2" Then sh.Cells(iRow, 8) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 3"
Then sh.Cells(iRow, 9) = Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf
seminar = "Seminar 4" Then sh.Cells(iRow, 10) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 5"
Then sh.Cells(iRow, 11) = Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") End
If Exit Sub End If Next iRow ' Ako JMBG ne postoji u spisku, unesite nove podatke With
sh .Cells(iRow, 1) = iRow - 1 ' Automatski broj redova .Cells(iRow, 2) =
frmForm.txtImep.Value .Cells(iRow, 3) = jmbg .Cells(iRow, 4) =
frmForm.txtMesto.Value .Cells(iRow, 12) = IIf(frmForm.optPutnik.Value = True, "Prevoz putnika",
"Prevoz tereta") .Cells(iRow, 6) = frmForm.txtTelefon.Value .Cells(iRow, 5) = frmForm.txtOca.Value
seminar = frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then ' IZMENA: Promenite
datum na vrednost iz txtDatumIspisa sh.Cells(iRow, 7) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 2"
Then sh.Cells(iRow, 8) = Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf
seminar = "Seminar 3" Then sh.Cells(iRow, 9) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 4"
Then sh.Cells(iRow, 10) = Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY")
ElseIf seminar = "Seminar 5" Then sh.Cells(iRow, 11) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") End If End With End Sub Sub
SetEditData() With frmForm .txtRowNumber.Value = Selected_List() + 1 .txtID.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 2) .txtImep.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 1) Dim sTransport As String sTransport
= .lstDatabase.List(.lstDatabase.ListIndex, 11) If sTransport = "Prevoz tereta" Then .optTeret.Value
= True Else .optPutnik.Value = True End If .cmbSeminar.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 6) .txtTelefon.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 5) .txtMesto.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 3) ' IZMENA: Postavite vrednost txtDatumIspisa na
vrednost iz tabele .txtDatumispisa.Value = .lstDatabase.List(.lstDatabase.ListIndex, 7) End With
End Sub Sub UpdateData() Dim sh As Worksheet Dim selectedRow As Long Set sh =
ThisWorkbook.Sheets("Database") selectedRow = frmForm.txtRowNumber.Value With sh
If .Cells(selectedRow, 3).Value = "" Then MsgBox "Selected row is empty. Cannot update.",
vbOKOnly + vbExclamation, "Update Error" Exit Sub End If ' Update podataka na odabranoj
poziciji .Cells(selectedRow, 2) = frmForm.txtImep.Value .Cells(selectedRow, 3) =
frmForm.txtID.Value .Cells(selectedRow, 4) = frmForm.txtMesto.Value .Cells(selectedRow, 12) =
IIf(frmForm.optPutnik.Value = True, "Prevoz putnika", "Prevoz tereta") .Cells(selectedRow, 6) =
frmForm.txtTelefon.Value .Cells(selectedRow, 5) = frmForm.txtOca.Value Dim seminar As String
seminar = frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then ' IZMENA: Promenite
datum na vrednost iz txtDatumIspisa sh.Cells(selectedRow, 7) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 2"
Then sh.Cells(selectedRow, 8) = Format(DateValue(frmForm.txtDatumispisa.Value),
"DD.MM.YYYY") ElseIf seminar = "Seminar 3" Then sh.Cells(selectedRow, 9) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") ElseIf seminar = "Seminar 4"
Then sh.Cells(selectedRow, 10) = Format(DateValue(frmForm.txtDatumispisa.Value),
"DD.MM.YYYY") ElseIf seminar = "Seminar 5" Then sh.Cells(selectedRow, 11) =
Format(DateValue(frmForm.txtDatumispisa.Value), "DD.MM.YYYY") End If End With End Sub
Function Selected_List() As Long Dim i As Long Selected_List = 0 For i = 0 To
frmForm.lstDatabase.ListCount - 1 If frmForm.lstDatabase.Selected(i) = True Then Selected_List =
i + 1 Exit For End If Next i End Function I ovo je module: Option Explicit Sub Reset() Dim iRow As
Long iRow =
ThisWorkbook.Sheets("Database").Cells(ThisWorkbook.Sheets("Database").Rows.Count,
1).End(xlUp).Row + 1 ' Identifikacija poslednjeg reda With frmForm .txtID.Value =
"" .txtImep.Value = "" .txtOca.Value = "" .optTeret.Value = False .optPutnik.Value =
False .cmbSeminar.Clear .cmbSeminar.AddItem "Seminar 1" .cmbSeminar.AddItem "Seminar
2" .cmbSeminar.AddItem "Seminar 3" .cmbSeminar.AddItem "Seminar 4" .cmbSeminar.AddItem
"Seminar 5" .txtRowNumber.Value = "" .txtTelefon.Value = "" .txtMesto.Value =
"" .lstDatabase.ColumnCount = 12 ' Dodajte jedan za "Redni broj" .lstDatabase.ColumnHeads =
True .lstDatabase.ColumnWidths = "20,100,70,60,70,70,70,70,70,70,,70,70" ' Prilagodite širine
kolona If iRow > 1 Then .lstDatabase.RowSource = "Database!A2:L" & iRow
Else .lstDatabase.RowSource = "Database!A2:L2" End If End With End Sub Sub Submit() Dim sh
As Worksheet Dim iRow As Long Dim seminar As String Dim jmbg As String Set sh =
ThisWorkbook.Sheets("Database") If frmForm.txtRowNumber.Value = "" Then iRow =
sh.Cells(sh.Rows.Count, 1).End(xlUp).Row + 1 Else iRow = frmForm.txtRowNumber.Value End If
jmbg = frmForm.txtID.Value ' Provera da li JMBG ve? postoji u spisku For iRow = 2 To
sh.Cells(sh.Rows.Count, 3).End(xlUp).Row If sh.Cells(iRow, 3).Value = jmbg Then ' JMBG ve?
postoji, ažuriramo samo datum seminara i ostavljamo postoje?e datume netaknutim seminar =
frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then sh.Cells(iRow, 7) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 2" Then sh.Cells(iRow, 8) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 3" Then sh.Cells(iRow, 9) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 4" Then sh.Cells(iRow, 10) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 5" Then sh.Cells(iRow, 11) = Format(Date,
"DD.MM.YYYY") End If Exit Sub End If Next iRow ' Ako JMBG ne postoji u spisku, unesite nove
podatke With sh .Cells(iRow, 1) = iRow - 1 ' Automatski broj redova .Cells(iRow, 2) =
frmForm.txtImep.Value .Cells(iRow, 3) = jmbg .Cells(iRow, 4) =
frmForm.txtMesto.Value .Cells(iRow, 12) = IIf(frmForm.optPutnik.Value = True, "Prevoz putnika",
"Prevoz tereta") .Cells(iRow, 6) = frmForm.txtTelefon.Value .Cells(iRow, 5) = frmForm.txtOca.Value
seminar = frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then sh.Cells(iRow, 7) =
Format(Date, "DD.MM.YYYY") ElseIf seminar = "Seminar 2" Then sh.Cells(iRow, 8) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 3" Then sh.Cells(iRow, 9) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 4" Then sh.Cells(iRow, 10) = Format(Date,
"DD.MM.YYYY") ElseIf seminar = "Seminar 5" Then sh.Cells(iRow, 11) = Format(Date,
"DD-.MM.YYYY") End If End With End Sub Sub SetEditData() With frmForm .txtRowNumber.Value
= Selected_List() + 1 .txtID.Value = .lstDatabase.List(.lstDatabase.ListIndex, 2) .txtImep.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 1) Dim sTransport As String sTransport
= .lstDatabase.List(.lstDatabase.ListIndex, 12) If sTransport = "Prevoz tereta" Then .optTeret.Value
= True Else .optPutnik.Value = True End If .cmbSeminar.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 6) .txtTelefon.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 5) .txtMesto.Value
= .lstDatabase.List(.lstDatabase.ListIndex, 3) End With End Sub Sub UpdateData() Dim sh As
Worksheet Dim selectedRow As Long Set sh = ThisWorkbook.Sheets("Database") selectedRow =
frmForm.txtRowNumber.Value With sh If .Cells(selectedRow, 3).Value = "" Then MsgBox
"Selected row is empty. Cannot update.", vbOKOnly + vbExclamation, "Update Error" Exit Sub
End If ' Update podataka na odabranoj poziciji .Cells(selectedRow, 2) =
frmForm.txtImep.Value .Cells(selectedRow, 3) = frmForm.txtID.Value .Cells(selectedRow, 4) =
frmForm.txtMesto.Value .Cells(selectedRow, 12) = IIf(frmForm.optPutnik.Value = True, "Prevoz
putnika", "Prevoz tereta") .Cells(selectedRow, 6) = frmForm.txtTelefon.Value Dim seminar As
String seminar = frmForm.cmbSeminar.Value If seminar = "Seminar 1" Then
sh.Cells(selectedRow, 7) = Format(Date, "DD.MM.YYYY") ElseIf seminar = "Seminar 2" Then
sh.Cells(selectedRow, 8) = Format(Date, "DD.MM.YYYY") ElseIf seminar = "Seminar 3" Then
sh.Cells(selectedRow, 9) = Format(Date, "DD.MM.YYYY") ElseIf seminar = "Seminar 4" Then
sh.Cells(selectedRow, 10) = Format(Date, "DD.MM.YYYY") ElseIf seminar = "Seminar 5" Then
sh.Cells(selectedRow, 11) = Format(Date, "DD.MM.YYYY") End If End With End Sub Function
Selected_List() As Long Dim i As Long Selected_List = 0 For i = 0 To
frmForm.lstDatabase.ListCount - 1 If frmForm.lstDatabase.Selected(i) = True Then Selected_List =
i + 1 Exit For End If Next i End Function