473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Inserting Option Button Group Values into SQL server

6
This is what I'm trying to do. I created a form for a user to enter a name. The information is saved in SQL DB employees table. The employees table auto number is assign to global variable GBL_ID as shown is first code. By clicking the proceed button on the first form I can follow the GBL_ID variable to the second form in debug mode.

While hitting F8 I can follow the process until a I get an error message:
Object variable or with block variable not set.

What am I doing wrong? It's got to be so simple. Any help will be appreciated. Thanks.

-------------------------------------------------------------------------------------------------------

Private Sub Btn_Proceed_Click()
On Error GoTo Err_Btn_Proceed_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim strFields As String
Dim strQueryName As String

If IsEmpty(Trim(Me!Text31)) Or IsNull(Trim(Me!Text31)) Or Trim(Me!Text31) = "" Then
MsgBox "Please enter your First Name"
Exit Sub
End If
If IsEmpty(Trim(Me!Text33)) Or IsNull(Trim(Me!Text33)) Or Trim(Me!Text33) = "" Then
MsgBox "Please enter your Last Name"
Exit Sub
End If

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

'set ID to global value
GBL_ID = CInt(Me.Text48)

'Insert a new record and create a new query for CPA Table
DoCmd.RunSQL "Insert into CPA (ID) values (" & GBL_ID & ");"
strSQL = "Select * from CPA where ID = " & GBL_ID & " ;"

DoCmd.Close acForm, Me.Name

stDocName = "CPA_form_1"

stLinkCriteria = "ID = " & GBL_ID
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Btn_Proceed_Click:
Exit Sub

Err_Btn_Proceed_Click:
MsgBox Err.Description
Resume Exit_Btn_Proceed_Click

End Sub

--------------------------------------------------------------------------------------------

Private Sub Continue1_button_Click()
On Error GoTo Err_Continue1_button_Click

Dim stDocName As String
Dim stLinkCriteria As String

'Validates Option Buttons have been chosen
If Me.Frame1.Value = 0 Then

MsgBox "Please recheck answer(s) to ensure option button was selected."
'Me.Frame1.BackColor = RGB(255, 0, 0)
Exit Sub
End If

'Insert a new record and create a new query for CPA Table
CurrentDb.Execute "Insert into CPA (Q1) values (" & Me.Frame1 & ");"
strSQL = "Select Q1 from CPA where ID = " & GBL_ID & " ;"


stDocName = "CPA_form_2"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Continue1_button_Click:
Exit Sub

Err_Continue1_button_Click:
MsgBox Err.Description
Resume Exit_Continue1_button_Click

End Sub
Jun 26 '07 #1
0 1582

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Geoff Wickens | last post by:
I am quite new to all this but am trying to create a database driven site. I have been able to use information from my sample database but I now want to be able to insert data into it. At present I...
14
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
1
by: Stephen D Cook | last post by:
What I am trying to do is have a set of option buttons which are required to click one. If the person doesn't click any before insert, they get an error. If they do click one, it inserts into the...
1
by: Stephen D Cook | last post by:
In my form I have an option group with 3 option buttons. My form is tied to a table. the options are Temp, Permanent and Overtime. I have these inside a frame. I have an AddRecord button to enter...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
4
by: sialater | last post by:
Hello, I realise there are a lot of topics related to this problem but many of what I have found has run cold or unresolved. What I have is an addressbook clone where there are groups which have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.