PC Review


Reply
Thread Tools Rate Thread

add to drop down list

 
 
Steve Goodrich
Guest
Posts: n/a
 
      7th Jun 2010
I have a table listing departments which I use to populate a drop down combo
box on my form - property set to limit to list

What is the best way for the user to add a new dept to this list without
going to the table?

Steve


 
Reply With Quote
 
 
 
 
Steve Goodrich
Guest
Posts: n/a
 
      8th Jun 2010
Thanks for your reply,

I pasted the text into the not on list event but the 2 lines below were in
red and when I tried to add a new dept on my form I got a syntax error
message and it pointed back to the lines which were in red.

If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
vbYesNo, "Unknown dept") = vbYes Then

have you any idea what the error could be, I have no experience with vba
many thanks
Steve


"XPS35" <(E-Mail Removed)> wrote in message
news:hul32p$2cco$(E-Mail Removed)...
> Steve Goodrich wrote:
>
>> I have a table listing departments which I use to populate a drop down
>> combo
>> box on my form - property set to limit to list
>>
>> What is the best way for the user to add a new dept to this list without
>> going to the table?
>>
>> Steve
>>
>>

>
> You can use the not-in-list even. It looks something like:
>
> Private Sub Dept_NotInList(NewData As String, Response As Integer)
>
> If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
> vbYesNo, "Unknown dept") = vbYes Then
> DoCmd.RunSQL "INSERT INTO Dept(Dept) VALUES('" & NewData & "')"
> Response = acDataErrAdded
> Else
> Response = acDataErrContinue
> End If
> End Sub
>
> --
> Groeten,
>
> Peter
> http://access.xps350.com
>
>
> --- news://freenews.netfront.net/ - complaints: (E-Mail Removed) ---



 
Reply With Quote
 
XPS350
Guest
Posts: n/a
 
      8th Jun 2010
On 8 jun, 17:25, "Steve Goodrich" <stevegoodr...@btinternet.com>
wrote:
> Thanks for your reply,
>
> I pasted the text into the not on list event but the 2 lines below were in
> red and when I tried to add a new dept on my form I got a syntax error
> message and it pointed back to the lines which were in red.
>
> If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
> vbYesNo, "Unknown dept") = vbYes Then
>
> have you any idea what the error could be, I have no experience with vba
> many thanks
> Steve
>
> "XPS35" <xps...@gmail.com> wrote in message
>
> news:hul32p$2cco$(E-Mail Removed)...
>
> > Steve Goodrich wrote:

>
> >> I have a table listing departments which I use to populate a drop down
> >> combo
> >> box on my form - property set to limit to list

>
> >> What is the best way for the user to add a new dept to this list without
> >> going to the table?

>
> >> Steve

>
> > You can use the not-in-list even. It looks something like:

>
> > Private Sub Dept_NotInList(NewData As String, Response As Integer)

>
> > If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
> > vbYesNo, "Unknown dept") = vbYes Then
> > * *DoCmd.RunSQL "INSERT INTO Dept(Dept) VALUES('" & NewData & "')"
> > * *Response = acDataErrAdded
> > Else
> > * *Response = acDataErrContinue
> > End If
> > End Sub

>
> > --
> > Groeten,

>
> > Peter
> >http://access.xps350.com

>
> > --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---


The 2 lines (If ... Then) must be 1 line in the code. Long lines
like this do not fit in messages in this group.

Groeten,

Peter
http://access.xps350.com
 
Reply With Quote
 
Steve Goodrich
Guest
Posts: n/a
 
      8th Jun 2010
Many thanks, works perfectly now
Steve
"XPS350" <(E-Mail Removed)> wrote in message
news:71e03706-2a3d-47ce-a2ab-(E-Mail Removed)...
On 8 jun, 17:25, "Steve Goodrich" <stevegoodr...@btinternet.com>
wrote:
> Thanks for your reply,
>
> I pasted the text into the not on list event but the 2 lines below were in
> red and when I tried to add a new dept on my form I got a syntax error
> message and it pointed back to the lines which were in red.
>
> If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
> vbYesNo, "Unknown dept") = vbYes Then
>
> have you any idea what the error could be, I have no experience with vba
> many thanks
> Steve
>
> "XPS35" <xps...@gmail.com> wrote in message
>
> news:hul32p$2cco$(E-Mail Removed)...
>
> > Steve Goodrich wrote:

>
> >> I have a table listing departments which I use to populate a drop down
> >> combo
> >> box on my form - property set to limit to list

>
> >> What is the best way for the user to add a new dept to this list
> >> without
> >> going to the table?

>
> >> Steve

>
> > You can use the not-in-list even. It looks something like:

>
> > Private Sub Dept_NotInList(NewData As String, Response As Integer)

>
> > If MsgBox("This dept is not in the list." & vbCrLf & vbCrLf & "Add it?",
> > vbYesNo, "Unknown dept") = vbYes Then
> > DoCmd.RunSQL "INSERT INTO Dept(Dept) VALUES('" & NewData & "')"
> > Response = acDataErrAdded
> > Else
> > Response = acDataErrContinue
> > End If
> > End Sub

>
> > --
> > Groeten,

>
> > Peter
> >http://access.xps350.com

>
> > --- news://freenews.netfront.net/ - complaints: n...@netfront.net ---


The 2 lines (If ... Then) must be 1 line in the code. Long lines
like this do not fit in messages in this group.

Groeten,

Peter
http://access.xps350.com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop List Options Dependent On Another Drop Down List Option =?Utf-8?B?U2lkbmV5Y2hpYy5BZG1pbg==?= Microsoft Word Document Management 9 24th Jul 2007 09:15 PM
Re: drop down list choice resulting in data for next drop down list Al Campagna Microsoft Access 0 30th Nov 2006 07:19 PM
Re: drop down list choice resulting in data for next drop down list Jeff Boyce Microsoft Access 0 30th Nov 2006 07:14 PM
multiple select from the drop down list in excel. list in one sheet and drop down in sriramus Microsoft Excel Misc 5 27th Oct 2005 06:55 PM
Drop-down List where items in drop-down list hyperlink to a webpage? gully Microsoft Word New Users 4 24th Apr 2005 09:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.