SQL - Insert Into (1 Viewer)

durdle

Registered User.
Local time
Today, 12:14
Joined
May 7, 2002
Messages
130
Good day,

I am using the Cascading Combo Boxes on my form and I want to add the "Number Value" of my boxes to my table and not the Text value. The setup of my boxes is:
tblcategory
- categoryid
- CategoryName

tbltype
- typeid
- typeName
- categoryid

tbldetail
- detailid
- detailName
- typeid
- categoryid

The SQL that I am using is

Dim SqlStr As String


SqlStr = "INSERT INTO tblclose (casenum, category, type, detail) Values" _
& "('" & Forms!frmupdate!frmupdatesub!casenum & "', '" & Forms!frmupdate!frmupdatesub!cbocat & "', '" & Forms!frmupdate!frmupdatesub!cbotype & "'," _
& "'" & Forms!frmupdate!frmupdatesub!cbodetail & "', #")"

DoCmd.RunSQL (SqlStr)

The values of combo boxes do not be entered(just blank), just the casenum. Just wondering if anyone can help me out and tell me how I can "Lookup" the values of the combo id's in the corresponding tables!
Hopefully this is clear!

Thanks
________
crown comfort
 
Last edited:

WayneRyan

AWF VIP
Local time
Today, 12:14
Joined
Nov 19, 2002
Messages
7,122
Durdle,

The sql that populates your combos should be something like:

Code:
Select SomeID, SomeText
From   YourTable
Order by SomeText

When you look at your combo in Design View, it should have two columns,
their widths should be something like 0";1". Hide the first column, the
user doesn't need to see it.

Then, in your code reference it by: Me.YourCombo.Column(0), meaning
the first column. Me.YourCombo.Column(1) would reference the text
part (column 2).

Wayne
 

durdle

Registered User.
Local time
Today, 12:14
Joined
May 7, 2002
Messages
130
Hey Wayne,
Thanks for the reply.

I figured out my problem with the combo boxes. But now I am having trouble with two other fields on my form. I have attached my database to make this a little more clear. If you open it up and click on the "Update/Close Stuff" button, and type the number 18 in the search field on top of the next screen. It will bring you to the form I am having trouble with, the "frmupdate" and "frmupdatesub". The object here is the move the data from the "tblopenref" to the "tblclose" if the user selects "Close" from the drop down. So select "Closed" from the drop down and enter a "Close Date" down below. Next click the Update button. Here I have the SQL moving the data from the tblopenref to the tblclose, then I have a delete query to delete the data from the tblopenref. Only problem is when you open the tblclose, the Status field still shows Open and there is not Close Date in the table.

Any help would be great, I am in a small jam here @ work.
I had to remove alot from the db b/c it was too big

Thanks alot
________
hash
 

Attachments

  • sample_db.zip
    96.1 KB · Views: 96
Last edited:

WayneRyan

AWF VIP
Local time
Today, 12:14
Joined
Nov 19, 2002
Messages
7,122
Durdle,

The combos on your subform, have no rowsource!

And, they are restricted to the list! Which equals nothing.

Wayne
 

Users who are viewing this thread

Top Bottom