If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding data to a form
Hi
As as subform I have a continuous form showing a list of contacts. To make it easier to read, I have concatenated the Title, Forename and Surname fields into a single field called Full Name I wanted to give the user an option that if they type in a name not in list, that they can add it to the contacts table via a form frmAddContact. I used the following code: Dim s As String Dim x As Long s = NewData & " is not in the list" s = s & vbNewLine & "would you like to add it?" x = MsgBox(s, vbQuestion + vbYesNo, "Not In List") If x = vbYes Then DoCmd.OpenForm "frmAddContact", acNormal, , , acFormAdd, acDialog, NewData Response = acDataErrAdded Else Response = acDataErrContinue End If Hpwever of course that places all of the NewData into the first field on the form which is the Title field. Id there a way tp split it up (perhaps based on spaces in the NewData string) or is there another way of achieving what I want? Many thanks Alex |
#2
|
|||
|
|||
Adding data to a form
It's inadvisable to try to parse a name.
Have the user enter the name in a form that has separate controls for firstname, middleinitial and lastname. -- Dorian "Give someone a fish and they eat for a day; teach someone to fish and they eat for a lifetime". "Alex Hammerstein" wrote: Hi As as subform I have a continuous form showing a list of contacts. To make it easier to read, I have concatenated the Title, Forename and Surname fields into a single field called Full Name I wanted to give the user an option that if they type in a name not in list, that they can add it to the contacts table via a form frmAddContact. I used the following code: Dim s As String Dim x As Long s = NewData & " is not in the list" s = s & vbNewLine & "would you like to add it?" x = MsgBox(s, vbQuestion + vbYesNo, "Not In List") If x = vbYes Then DoCmd.OpenForm "frmAddContact", acNormal, , , acFormAdd, acDialog, NewData Response = acDataErrAdded Else Response = acDataErrContinue End If Hpwever of course that places all of the NewData into the first field on the form which is the Title field. Id there a way tp split it up (perhaps based on spaces in the NewData string) or is there another way of achieving what I want? Many thanks Alex |
Thread Tools | |
Display Modes | |
|
|