473,396 Members | 1,846 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,396 software developers and data experts.

Record Not Saved In Table & Does not show up in the Form

I have been working with a database that was already created by somebody else, who now no longer works here, so I cant ask any questions.

None the less, there is a table 'Ascertainment' which prior to my changes new record was saved in the Table, but when you bring up the form it was blank, the input for new record consisted of Text Boxes.

I wanted to validate the data, and changed the text boxes to combo boxes, now new record does not save in the table at all, as well as does not show up in the form. Please Help, here is the Action code to when you click the 'Done' Button.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmdDone_Click()
  4.  
  5.     Dim response As Integer
  6.     Dim strLinkCriteria As String
  7.     Dim curIDNum As String
  8.     Dim txtRqd As String
  9.     If IsNull(Me![txtIDNUMBER]) Then
  10.         curIDNum = ""
  11.     Else
  12.         curIDNum = Me![txtIDNUMBER]
  13.     End If
  14.  
  15.     strLinkCriteria = "[IDNUMBER] = " & """" & curIDNum & """"
  16.     strFormName = "Main"
  17.  
  18.     If Me.Dirty = True Then
  19.         'user has entered or made changes to data on form
  20.         response = MsgBox("Would you like to save changes?", vbYesNoCancel)
  21.         If response = vbYes Then
  22.             'check for required textboxes (tagged 1 on form) without entries
  23.             txtRqd = checkRqdEntries(Me.Name, 1)
  24.             If Not txtRqd = "" Then
  25.                 MsgBox txtRqd & " requires data before you proceed.", vbCritical
  26.                 Exit Sub
  27.             End If
  28.             DoCmd.Close acForm, Me.Name
  29.             'continue on to main page
  30.             If intaddentry = 1 Then
  31.                 'open main page in entry mode
  32.                 DoCmd.OpenForm "Main", , , , acFormAdd
  33.                 [Forms]("Main")![IDNUMBER] = curIDNum
  34.             'Else
  35.                 'open main page with corresponding record in contacts table
  36.                 'DoCmd.OpenForm "Main", , , strLinkCriteria
  37.             End If
  38.         ElseIf response = vbNo Then
  39.             Me.Undo
  40.             DoCmd.Close acForm, Me.Name
  41.             'if user decides not to save new patient, switchboard will open
  42.             'otherwise:
  43.             'If Not intaddentry = 1 Then
  44.                 'user has chosen not to save changes made to existing patient
  45.             '    DoCmd.OpenForm "Main", , , strLinkCriteria
  46.             'End If
  47.         Else
  48.             'cancel
  49.             strFormName = "Ascertainment"
  50.             Exit Sub
  51.         End If
  52.     Else
  53.         'no changes have been made to the data on the form
  54.         DoCmd.Close acForm, Me.Name
  55.         'if user decides not to save new patient, switchboard will open
  56.         'otherwise:
  57.         'If Not intaddentry = 1 Then
  58.         '    DoCmd.OpenForm "Main", , , strLinkCriteria
  59.         'End If
  60.     End If
  61. End Sub
Mar 17 '08 #1
11 3185
Also I wanted to add that in the "Main" Form I have a button that leads to the "Ascertainment" form and here is the code to that button, just in case this helps with understanding why there is a problem.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAscertainment_Click()
  2.     Dim curID As String
  3.     Dim recordExists As Boolean
  4.     curID = Me![IDNUMBER]
  5.  
  6.     run = MainNavigate()
  7.     If boolCancel = True Then
  8.         Exit Sub
  9.     Else
  10.         If run = False Then
  11.             DoCmd.Close acForm, Me.Name
  12.             Exit Sub
  13.         Else
  14.             recordExists = FindRecord("Ascertainment", "IDNUMBER", curID)
  15.             If recordExists Then
  16.                 DoCmd.OpenForm "Ascertainment", , , "[IDNUMBER] = """ & curID & """"
  17.             Else
  18.                 DoCmd.OpenForm "Ascertainment", , , , acFormAdd
  19.                 [Forms]("Ascertainment")![txtIDNUMBER] = curID
  20.             End If
  21.         End If
  22.     End If
  23. End Sub
Mar 17 '08 #2
Scott Price
1,384 Expert 1GB
Hello AndrewDB,

When including code in your thread, and especially when including such a long portion of code, please use the [code] tags provided, as indicated in the Reply Guidelines to the right of the Reply/Message window. They are simple to use: select your code text, then click on the # icon on menu bar of the Message window.

MODERATOR
Mar 17 '08 #3
Anyone?
Please?
Maybe?
Mar 18 '08 #4
Scott Price
1,384 Expert 1GB
The code you have posted doesn't have any references in it to the text boxes converted to combo boxes that you mentioned having changed. Also, there is a reference in Line 23 of your first post to a user defined function named: chkRqdEntries...

Please indicate what code you changed, and post the relevant code changes. Please also post the code for the chkRqdEntries function.

Regards,
Scott
Mar 18 '08 #5
Thats the thing, the only thing I have changed was not the actual code, but from the Form 'Ascertainment' where there were fields, I took them out and replaced them with combo boxes. Thats all, fortunately I have fixed the problem of new records not being recorded. Thats half the battle. But I still can not understand why entered records do not show up when I click on the 'Ascertainment' button from the 'Main' menu? Its just a blank form, even though the record exists in the Table.

Please Help.

Here is the code for the function you have asked:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Function checkRqdEntries(frmName As String, tagNo As Integer) As String
  4.     Dim contrl As Control
  5.     checkRqdEntries = ""
  6.     For Each contrl In [Forms](frmName).Controls
  7.         If TypeName(contrl) = "TextBox" And contrl.Tag = tagNo Then
  8.             If IsNull(contrl) Then
  9.                 checkRqdEntries = contrl.Name
  10.                 Exit Function
  11.             End If
  12.         End If
  13.     Next contrl
  14. End Function
  15.  
Thank You for your Time
Mar 18 '08 #6
Scott Price
1,384 Expert 1GB
What's the control source of your combo boxes? Combo boxes have both a control source and a row source.

I'm assuming you have set the row source correctly, but nothing will initially show in the combo box if you do not set the control source.

Regards,
Scott
Mar 18 '08 #7
Row Source contains the two columns that are my 'Choices' with description that I want to display, and the corresponding code number that I want to store in the table.

Control Source is the reference to the variable/column where the information is being stored in the table. In one of the cases for example I have a combo box for 'Referred by' which is stored in my 'Ascertainment' table under variable REFDBY, which is the control source for that combo box.

So it does seem like there is reference to it, I just don't understand why it wont display, very strange.

Andrew
Mar 19 '08 #8
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Function checkRqdEntries(frmName As String, tagNo As Integer) As String
  4.     Dim contrl As Control
  5.     checkRqdEntries = ""
  6.     For Each contrl In [Forms](frmName).Controls
  7.         If TypeName(contrl) = "TextBox" And contrl.Tag = tagNo Then
  8.             If IsNull(contrl) Then
  9.                 checkRqdEntries = contrl.Name
  10.                 Exit Function
  11.             End If
  12.         End If
  13.     Next contrl
  14. End Function
  15.  
I'm not still clear on exactly what you're doing here, but in Line # 7 of the above code you have a line

If TypeName(contrl) = "TextBox" And contrl.Tag = tagNo Then


Since you've converted some textboxes to comboboxes you may need to modify this code to to include comboboxes.

Linq ;0)>
Mar 19 '08 #9
How would I do that?

Would it be like this?

If (TypeName(contrl) = "TextBox" OR "ComboBox") And contrl.Tag = tagNo Then

?
Mar 19 '08 #10
missinglinq
3,532 Expert 2GB
No, when using And/Or you have to include the complete evaluation expression

Expand|Select|Wrap|Line Numbers
  1.  If (TypeName(contrl) = "TextBox" OR TypeName(contrl) = "ComboBox") And contrl.Tag = tagNo Then
Linq ;0)>
Mar 19 '08 #11
I have tried that as well, nothing changes. Still the when I click on the button the Form comes up with empty cells/combo boxes. How strange! WHY? Anybody?
Mar 25 '08 #12

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

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
0
by: elvin | last post by:
Okay - apologize in advance for the length, but I want to make sure all you knowledgeable and helpful people have all the details you need to hopefully point my newbie rear in the right direction....
2
by: Tim ffitch | last post by:
Hi Here is my setup. 5 users on NT4 workstations each with front end Access 97 db linked to NT4 server which has back end data file. A user selects a supplier from a pop up form. The main form...
0
by: MLH | last post by:
Edit, Insert Object & choose Wave Object, the following OLE object thing gets inserted onto the form... Microsoft Sound Recorder Version 5.1 (Build 2600.xpsp2.030422-1633: Service Pack 1)...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
27
by: Kim Webb | last post by:
I have a field on a form for project number. I basically want it to be the next available number (ie 06010 then 06011 etc). In the form I create a text box and under control source I put: =!=...
1
by: terry.statham | last post by:
Hope someone can help me here. I am fairly new to Access. I have set up a database relating to vehicle movements prior to sale. I have a subform based on 'locations' table which is linked to my...
25
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.