How do i update table from form???

  • Thread starter Thread starter helenchadders
  • Start date Start date
H

helenchadders

Guest
Hey!

I have a system which allows me to match work placements for a school but i have come across a problem. When i have matched a pupil with possible placements im having trouble selecting one placement and then performing an event which will update a table. I have a form which is run by asking the pupils what their unigue ID is and their category choice, once this is entered the results are displayed in the form. From here i want to be able to select one group and have a macro (or something) which allows me to transport the information to a seperate table. I have already tried using macro's, option groups, check boxes and queries but something isn't working correctly.

PLEASE HELP ME!!!!!!!!!!!!

:confused:
 
Usually a form is used to be a graphical front end to display a set of data from an underlying table or query. From your description, I'm assuming that you will have tables for students (and all related info), Placements (a/a) and Students_Placements.
It seems like your form is throwing up the data from a query which you then want to select a choice for that student. You would not normally need to code to transpose the data, just have the correct recordsource for the form that allows the relevant fields to be updated.
Does this help ?
 
Hi: I'm not sure if this is applicable to what you are doing, but I had an application where I matched boats with multiple boat parts. (Table Parts_Boats basically had two fields that held related pairs). I had a multi-select list of boat parts (list control named 'Parts') and the user could select multiple parts, click a button to add or a button to delete the parts from the boat, and one of the following subs would be called. Here are two pieces of code one to add records to the table and one to delete selected parts from the Parts_Boats relationship table.

Private Sub Command52_Click()
' delete Parts_Boats data
On Error Resume Next
Dim db As Database
Dim intIndex As Integer
Dim ssql As String
Set db = CurrentDb()
With Me!FrmNewList!Parts
If .ItemsSelected.Count > 0 Then
' Any selection?
For intIndex = 0 To .ListCount - 1
If .Selected(intIndex) Then
ssql = "Delete FROM Parts_Boats where PartID = " _
& .ItemData(intIndex) & " And HullID = " & Me![Combo30]
db.Execute ssql
End If
Next intIndex
Me!FrmNewList!Parts.Requery
Me!FrmNewList!Parts.Repaint
Else
MsgBox "You haven't selected an entry in the " _
& "list box."
End If

End With
Exit_Command52_Click:
Exit Sub

Err_Command52_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command52_Click

End Sub

Private Sub Command53_Click()
' delete sample data
On Error Resume Next
Dim db As Database
Dim intIndex As Integer
Dim ssql As String
Set db = CurrentDb()
With Me!FrmNewList!Parts
If .ItemsSelected.Count > 0 Then
' Any selection?
For intIndex = 0 To .ListCount - 1
If .Selected(intIndex) Then
ssql = "INSERT INTO Parts_Boats (HullID, PartID)"
ssql = ssql & " VALUES (" _
& Me![Combo30] & ", " & .ItemData(intIndex) & ")"
db.Execute ssql
End If
Next intIndex
Me!FrmNewList!Parts.Requery
Me!FrmNewList!Parts.Repaint

Else
MsgBox "You haven't selected an entry in the " _
& "list box."
End If

End With
Exit_Command53_Click:
Exit Sub

Err_Command53_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command53_Click
End Sub
 

Users who are viewing this thread

Back
Top Bottom