Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: OnClick, If..then add to other table

Geek News

OnClick, If..then add to other table
"KAquestions" <kirstieadam[ at ]yahoo.com_(no_spam)> 12/5/2008 12:13:11 PM
Hi all,

I have been working on various code combinations for this, but not getting
anywhere. So was hoping someone could help.

I have a form with 1 bound text box "SID" (PK and FKthroughout DB) and 4
unbound check boxes, and a button called "Confirm"

What i want is when the user clicks "Confirm", if "CheckBox1" is ticked, add
a record to a table "tbl2" with "SID" from for form going to "SID" in the
table, and "Int" in the table becoming "1".

Or else, if the user ticks "Checkbox2", "SID" goes into table, with "Int"
becoming "2"

The table design is just 2 fields

SID
Int

Am i making sense?

Can anyone help?

K


RE: OnClick, If..then add to other table
April 12/5/2008 9:31:02 PM
Try using an SQL statement and the DoCmd.RunSQL to insert a new record into
your table..

Dim sSQL As String

sSQL = "INSERT INTO yourTableName ([Int],[SID])" & _
"VALUES (1," & ValueFromForm & ");"

DoCmd.RunSQL sSQL




"KAquestions" wrote:

[Quoted Text]
> Hi all,
>
> I have been working on various code combinations for this, but not getting
> anywhere. So was hoping someone could help.
>
> I have a form with 1 bound text box "SID" (PK and FKthroughout DB) and 4
> unbound check boxes, and a button called "Confirm"
>
> What i want is when the user clicks "Confirm", if "CheckBox1" is ticked, add
> a record to a table "tbl2" with "SID" from for form going to "SID" in the
> table, and "Int" in the table becoming "1".
>
> Or else, if the user ticks "Checkbox2", "SID" goes into table, with "Int"
> becoming "2"
>
> The table design is just 2 fields
>
> SID
> Int
>
> Am i making sense?
>
> Can anyone help?
>
> K
>
>
>
Re: OnClick, If..then add to other table
"KAquestions" <kirstieadam[ at ]yahoo.com_(no_spam)> 12/9/2008 2:40:29 PM
April,

Many thanks for this. Will have a go and let you know how i get on!

K

"April" <April[ at ]discussions.microsoft.com> wrote in message
news:D0B8F259-6FEB-4615-9B07-24AB4A8B3E4A[ at ]microsoft.com...
[Quoted Text]
> Try using an SQL statement and the DoCmd.RunSQL to insert a new record
> into
> your table..
>
> Dim sSQL As String
>
> sSQL = "INSERT INTO yourTableName ([Int],[SID])" & _
> "VALUES (1," & ValueFromForm & ");"
>
> DoCmd.RunSQL sSQL
>
>
>
>
> "KAquestions" wrote:
>
>> Hi all,
>>
>> I have been working on various code combinations for this, but not
>> getting
>> anywhere. So was hoping someone could help.
>>
>> I have a form with 1 bound text box "SID" (PK and FKthroughout DB) and 4
>> unbound check boxes, and a button called "Confirm"
>>
>> What i want is when the user clicks "Confirm", if "CheckBox1" is ticked,
>> add
>> a record to a table "tbl2" with "SID" from for form going to "SID" in the
>> table, and "Int" in the table becoming "1".
>>
>> Or else, if the user ticks "Checkbox2", "SID" goes into table, with "Int"
>> becoming "2"
>>
>> The table design is just 2 fields
>>
>> SID
>> Int
>>
>> Am i making sense?
>>
>> Can anyone help?
>>
>> K
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net