transfer items slected on a list box to form with a subdatasheet
Posted on 2006-06-06
Actually this is a 2 part question:
I am very comfortable using code to manipulate forms and reports. However the code I am using is not advanced enough to allow me to manipulate files or records which do not appear on the screen in a form. The type of code I speak of is for example, the code I acquired which adds the record to my table when a limit to list property is used. An example is below:
Private Sub ModelName_ID_NotInList(NewData As String, response As Integer)
Dim rst As Recordset
Dim Msg As String
Dim UserResponse As Integer
NewData = UCase(Mid(NewData, 1, 1)) & Mid(NewData, 2)
Msg = NewData & " is not on the list." & vbCr & "Would you like to add it?"
UserResponse = MsgBox(Msg, vbYesNo + vbQuestion, "Please Verify")
If UserResponse = vbYes Then
Set rst = CurrentDb.OpenRecordset("tblModel")
![model description] = NewData
response = acDataErrAdded
Set rst = Nothing
response = acDataErrContinue
Even though I understand what is going on, I have not had a need, until now, to undertake experimenting in this direction. Now the first question.
1) Conceptually, I would like to know a general series of steps I should take to manipulate data as in the above fashion. Should I always dim the current db then make a recordset etc. The preferred method of good code writing is what I am seeking. What I am afraid of is breaking the data I have now.
2) I have a form with a subform that has a datasheet view. I am doing estimate takeoff. So on the subform datasheet a new record is added to each line as the user picks from a combo box on each line. Since the items selected are usually the same or similar, I would like to have a pop up list box of the items a user can pick from (multiple selection property on) and when the list box is closed the items which were selected are written to the subform.
This may be alot to ask, but I am looking for direction more than just a solution.
many thanks in advance,