Implementations application & programming environ
MS Acess + Visual Basic
Expand|Select|Wrap|Line Numbers
- Table fields
- Serialno (pk) - Auto number
- StudentId - text
- Course - text
- intake - number
Expand|Select|Wrap|Line Numbers
- Control
- Combobox1 (StudentId) - predefined list
- TextBox1 (StudentId) - bound to controlsource StudentId
- TextBox2 (Course) - bound to controlsource course
- TextBox3(intake) userinput
Expand|Select|Wrap|Line Numbers
- Private_Sub_Combo1_AfterUpdate event
- Dim rs as Object
- Set rs = Me.RecordSetClone
- rs.FindFirst "[Serialno] = " Str(Nz(Me![Combo1]))
- If Not rs.EOF Then Me.Bookmark = rs.Bookmark
- Me.StudentId.value = Combo1.Column(0)
I have invoked the save command to add the below mentioned to Student table but i want to filter dupliacte student Id value selected from the combo box. I have set the field to Yes(No Duplicate) but getting an error this will allow duplicate value, refined index or remove duplicate in the fields. No idea as to what is it but i have provided the necessary info for review. Tks for assisting on this issue,
Expand|Select|Wrap|Line Numbers
- Private Sub_Save event
- On_Error.......
- Dim rs as RecordSet
- Dim db as Database
- Set rs = Me.RecordsetClone
- Set db = CurrentDb
- Set rs = db.OpenRecordSet("Select StudentId, Course, intake from Student where StudentId = '" & Me.StudentId.value & "' And Course = ''" & Me.Course.value & "')
- If Not rs.EOF Then
- rs.MoveNext
- rs.AddNew
- rs("StudentId").value = Combo1.value
- rs("Course").value = text2.value
- rs("intake").value = text3.value
- rs.update
- rs.close
- End If
- set rs = Nothing
- set db = Nothing
Expand|Select|Wrap|Line Numbers
- Private Sub AddRecord event
- DoCmd.OpenForm "StudentRecord", acNormal, ,StudnetId = '" & Me.Combo1.Value & "' And course = '" & Me.textBox2.value & "'
- DoCmd, acAddForm
- DoCmd.GoToRecord , , acNewRec