|
-
Feb 6th, 2007, 11:40 PM
#1
Thread Starter
Lively Member
combo box
how can i automatically add a new number when i click the combo box.
example my inside my combo box i have a course of NURSING, IT, Engineering
then i choose Nursing the txtBatchNUm will automatically generate NUR-0002.
hope anyone can help....
VB Code:
Private Sub cmdSave_Click()
With tbCourse
.MoveFirst
.Find "BatchNumber = '" & txtBatchNum & "'"
If .Fields(2) = txtBatchNum Then
MsgBox "Batch Number Already Exist.", vbInformation, "Titus School of Multimedia"
txtBatchNum = ""
txtBatchNum.SetFocus
ElseIf .EOF = True Then
.AddNew
AddFields
MsgBox "Batch Number successfully saved to the record.", vbInformation, "Titus School of Multimedia"
.Update
.Requery
txtBatchNum = ""
cmbCourse.Clear
cmbDepartment.Clear
txtNoSeat = ""
End If
End With
End Sub
Private Sub Form_Load()
With tbCourse
If .BOF = True And .EOF = True Then
Refresh
Else
Do Until .EOF
cmbCourse.AddItem (.Fields(0))
.MoveNext
Loop
End If
End With
With tbDepartment
If .BOF = True And .EOF = True Then
Refresh
Else
Do Until .EOF
cmbDepartment.AddItem (.Fields(0))
.MoveNext
Loop
End If
End With
End Sub
Private Sub AddFields()
With tbBatch
.Fields(0) = cmbCourse
.Fields(1) = txtNoSeat
.Fields(2) = txtBatchNum
.Fields(3) = cmbDepartment
End With
End Sub
-
Feb 6th, 2007, 11:49 PM
#2
Junior Member
Re: combo box
You can do this...example:-
Private Sub Combo1_Change()
if combo1.text = "NURSING" Then
txtBatchNUm.text = XXXXXX
end If
End Sub
-
Feb 6th, 2007, 11:54 PM
#3
Thread Starter
Lively Member
Re: combo box
theres a database for the course example
CourseName BatchNumber
Nursing Nur-0001
Engineering Eng-0001
IT IT-0001
the the combo box will be filled up by the Fields of the CourseName
example i choose Nursing the it will automatically add Nur-0002
-
Feb 7th, 2007, 12:16 AM
#4
Thread Starter
Lively Member
combo box
can anynone help me about combo box if i choose one in combo box the text box will automatically add a new number like this NUR-00001
VB Code:
Private Sub cmbCourse_Click()
a = cmbCourse.Text
'tmp = tbCourse.Fields(2)
Call rload
Do While tbCourse!CourseName <> a
tbCourse.MoveNext
If tbCourse!CourseName = a Then
txtBatchNum.Text = tbCourse!BatchNumber + temp
tmp = Left(tmp, 3) & (Format(CInt(Right(tmp, 4)) + 1, "00#"))
End If
Loop
End Sub
it have an error on
VB Code:
tmp = Left(tmp, 3) & (Format(CInt(Right(tmp, 4)) + 1, "00#"))
-
Feb 7th, 2007, 12:21 AM
#5
Frenzied Member
Re: combo box
You already asked this question.
-
Feb 7th, 2007, 12:26 AM
#6
Thread Starter
Lively Member
Re: combo box
yes can anyone help me with this
-
Feb 7th, 2007, 12:30 AM
#7
Re: combo box
 Originally Posted by mheiy
yes can anyone help me with this
I didn't get ..what is the value of temp???
-
Feb 7th, 2007, 12:33 AM
#8
Thread Starter
Lively Member
Re: combo box
the Batch Number have a format of this NUR-0001 how can i add another batch number with the same format
-
Feb 7th, 2007, 01:47 AM
#9
Re: combo box
you mean to say that you want to make the same format of a field to another field...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 7th, 2007, 02:03 AM
#10
Re: combo box
Hi
Does this help?
VB Code:
'If you want in this format NUR-0001
tmp = Left(tmp, 4) & Format(Right(tmp, 4)+1, "0000")
'If you want in this format NUR-00001
tmp = Left(tmp, 4) & Format(Right(tmp, 5)+1, "00000")
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 7th, 2007, 06:58 AM
#11
Re: combo box
Duplicate threads merged.
Please do not create more than one thread for the same question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|