alphil2001
Instructor
Hi All
Hope you can help with this one I have been going round in circles trying to figure it out.
I have a form called Add Student which has a number of text boxes to allow the information to be entered.
First Name
Last Name
Mobile
Telephone
Office (Combo box list of offices)
Address (Populated from office combo)
Code from unbound field in the control source is =[forms]![Add Student]![office].Column(4)
Address2 (Populated from office combo)
Area (Populated from office combo)
City (Populated from office Combo)
PostCode (Populated from office combo)
I have a combo box that has a list of offices that the user can choose from in the drop down list. The list has the office name, Address, Address2, Area, City and post code listed.
Once the user has selected the office from the combo list, other unbound fields are populated, so when a user selects the office "Accrington" from the combo box the Address fields etc are populated.
The probem I am having is that once this information has been filled in, I want to use a Append query to fill in two seperate tables. The append query will populate the tables with the field values if the user has physically typed into the fields (such as mobile and first and last name) the problem I am having is that the text that is populated in the unbound fields from the combo box is not being transfered but the physically typed text from First name and last name is being transfered so I know the query and the code is ok. Is there a different setting or code I need to use to pass or change value of the text from the unbound boxes that have been filled in automatically to the query as this isnt happening.
Here is my code:
Private Sub UpdateStudent_Click()
End Sub
On Error GoTo errhand
Dim frmstr As QueryDef
Dim dbservice As Database
Dim dbservice2 As Database
Set dbservice = CurrentDb
Set frmstr = dbservice.QueryDefs("UpdateStudent")
frmstr.Parameters![StudentID] = Me.StudentID
frmstr.Parameters![OfficeName] = Me.OfficeName.Text
frmstr.Parameters![RMU] = Me.RMU.Text
frmstr.Parameters![FirstName] = Me.FirstName.Text
frmstr.Parameters![LastName] = Me.LastName.Text
frmstr.Parameters![Directline] = Me.Directline.Text
frmstr.Parameters![Mobile] = Me.Mobile.Text
frmstr.Parameters![Phone] = Me.Phone.Text
frmstr.Parameters![Directorate] = Me.Directorate.Text
frmstr.Parameters![Jobtitle] = Me.Jobtitle.Text
frmstr.Parameters![Address] = Me.Address.Text
frmstr.Parameters![Address2] = Me.Address2.Text
frmstr.Parameters![Area] = Me.Area.Text
frmstr.Parameters![City] = Me.City.Text
frmstr.Parameters![PostalCode] = Me.PostalCode.Text
frmstr.Parameters! = Me.EMail.Text
frmstr.Parameters![UserName] = Me.UserName.Text
frmstr.Parameters![Notes] = Me.Notes.Text
frmstr.Parameters![Comments] = Me.Comments.Text
frmstr.Execute
Set dbservice2 = CurrentDb
Set frmstr = dbservice2.QueryDefs("UpdateStaff")
frmstr.Parameters![StudentID] = Me.StudentID
frmstr.Parameters![OfficeName] = Me.OfficeName.Text
frmstr.Parameters![FirstName] = Me.FirstName.Text
frmstr.Parameters![LastName] = Me.LastName.Text
frmstr.Parameters![Mobile] = Me.Mobile.Text
frmstr.Parameters![Phone] = Me.Phone.Text
frmstr.Parameters![Directorate] = Me.Directorate.Text
frmstr.Parameters![Jobtitle] = Me.Jobtitle.Text
frmstr.Parameters![EMail] = Me.EMail.Text
frmstr.Execute
Exit_rtn:
Exit Sub
errhand:
DoCmd.Hourglass False
Err.Clear
'Resume Exit_rtn
Exit_UpdateService:
Exit Sub
Do I also have to have the code for the second table in a seperate Sub form or can they be left as they are
Thank you for your help
Alphil2001
Hope you can help with this one I have been going round in circles trying to figure it out.
I have a form called Add Student which has a number of text boxes to allow the information to be entered.
First Name
Last Name
Mobile
Telephone
Office (Combo box list of offices)
Address (Populated from office combo)
Code from unbound field in the control source is =[forms]![Add Student]![office].Column(4)
Address2 (Populated from office combo)
Area (Populated from office combo)
City (Populated from office Combo)
PostCode (Populated from office combo)
I have a combo box that has a list of offices that the user can choose from in the drop down list. The list has the office name, Address, Address2, Area, City and post code listed.
Once the user has selected the office from the combo list, other unbound fields are populated, so when a user selects the office "Accrington" from the combo box the Address fields etc are populated.
The probem I am having is that once this information has been filled in, I want to use a Append query to fill in two seperate tables. The append query will populate the tables with the field values if the user has physically typed into the fields (such as mobile and first and last name) the problem I am having is that the text that is populated in the unbound fields from the combo box is not being transfered but the physically typed text from First name and last name is being transfered so I know the query and the code is ok. Is there a different setting or code I need to use to pass or change value of the text from the unbound boxes that have been filled in automatically to the query as this isnt happening.
Here is my code:
Private Sub UpdateStudent_Click()
End Sub
On Error GoTo errhand
Dim frmstr As QueryDef
Dim dbservice As Database
Dim dbservice2 As Database
Set dbservice = CurrentDb
Set frmstr = dbservice.QueryDefs("UpdateStudent")
frmstr.Parameters![StudentID] = Me.StudentID
frmstr.Parameters![OfficeName] = Me.OfficeName.Text
frmstr.Parameters![RMU] = Me.RMU.Text
frmstr.Parameters![FirstName] = Me.FirstName.Text
frmstr.Parameters![LastName] = Me.LastName.Text
frmstr.Parameters![Directline] = Me.Directline.Text
frmstr.Parameters![Mobile] = Me.Mobile.Text
frmstr.Parameters![Phone] = Me.Phone.Text
frmstr.Parameters![Directorate] = Me.Directorate.Text
frmstr.Parameters![Jobtitle] = Me.Jobtitle.Text
frmstr.Parameters![Address] = Me.Address.Text
frmstr.Parameters![Address2] = Me.Address2.Text
frmstr.Parameters![Area] = Me.Area.Text
frmstr.Parameters![City] = Me.City.Text
frmstr.Parameters![PostalCode] = Me.PostalCode.Text
frmstr.Parameters! = Me.EMail.Text
frmstr.Parameters![UserName] = Me.UserName.Text
frmstr.Parameters![Notes] = Me.Notes.Text
frmstr.Parameters![Comments] = Me.Comments.Text
frmstr.Execute
Set dbservice2 = CurrentDb
Set frmstr = dbservice2.QueryDefs("UpdateStaff")
frmstr.Parameters![StudentID] = Me.StudentID
frmstr.Parameters![OfficeName] = Me.OfficeName.Text
frmstr.Parameters![FirstName] = Me.FirstName.Text
frmstr.Parameters![LastName] = Me.LastName.Text
frmstr.Parameters![Mobile] = Me.Mobile.Text
frmstr.Parameters![Phone] = Me.Phone.Text
frmstr.Parameters![Directorate] = Me.Directorate.Text
frmstr.Parameters![Jobtitle] = Me.Jobtitle.Text
frmstr.Parameters![EMail] = Me.EMail.Text
frmstr.Execute
Exit_rtn:
Exit Sub
errhand:
DoCmd.Hourglass False
Err.Clear
'Resume Exit_rtn
Exit_UpdateService:
Exit Sub
Do I also have to have the code for the second table in a seperate Sub form or can they be left as they are
Thank you for your help
Alphil2001