473,508 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rst.update not working

1 New Member
Hi there tried creating new entry, it only works when the database is decompreste? weird I know.

can anyone help ?

thanks

PS: see code below

Expand|Select|Wrap|Line Numbers
  1. Dim HospitalNumber As String
  2. Dim strSQL0 As String
  3. dim LastName As String
  4. Dim FirstName As String
  5. Dim strDOB As String
  6.  
  7. If IsNull(Me.Text0.Value) Then
  8. strHospitalNumber = " Like '*' "
  9. Else
  10. strHospitalNumber = "='" & Me.Text0.Value & "' "
  11. End If
  12.  
  13. If IsNull(Me.Combo8.Value) Then
  14. strLastName = " Like '*' "
  15. Else
  16. strLastName = "='" & Me.Combo8.Value & "' "
  17. End If
  18.  
  19. If IsNull(Me.Combo10.Value) Then
  20. strFirstName = " Like '*' "
  21. Else
  22. strFirstName = "='" & Me.Combo10.Value & "' "
  23. End If
  24.  
  25. If IsNull(Me.DOB.Value) Then
  26. strDOB = " Like '*' "
  27. Else
  28. strDOB = "=" & "#" & Format(Me![DOB], "mm\/dd\/yyyy") & "# "
  29. End If
  30.  
  31.  
  32. strSQL0 = "SELECT Profile.* " & _
  33.          "FROM Profile " & _
  34.          "WHERE Profile.HospitalNumber" & strHospitalNumber & _
  35.          "AND Profile.LastName" & strLastName & _
  36.          "AND Profile.FirstName" & strFirstName & _
  37.          "AND Profile.DOB" & strDOB & _
  38.          "ORDER BY Profile.PtID;"
  39.  
  40. Set rst1 = CurrentDb.OpenRecordset(strSQL0)
  41.  
  42. If rst1.EOF Then
  43.  
  44. Dim Msg, Style, Title, Response
  45.  
  46. Msg = "There are no existing records for this patient in the database. To add this patient, click 'Yes'. To cancel and close this message box, click 'no'."
  47. Style = vbYesNo + vbDefaultButton2
  48. Title = "Would you like to add this patient to the database?"
  49. Response = MsgBox(Msg, Style, Title)
  50.  
  51. If Response = vbYes Then
  52.  
  53. rst1.Close
  54.  
  55. DoCmd.SetWarnings (WarningsOff)
  56.  
  57.   Set rst2 = CurrentDb.OpenRecordset("Profile")
  58.  
  59.   rst2.AddNew
  60.       rst2![HospitalNumber] = Me![Text0] 'the field from your form that matches the table column
  61.       rst2![LastName] = Me![Combo8]
  62.       rst2![FirstName] = Me![Combo10]
  63.       rst2![DOB] = Me![DOB]
  64.  
  65. rst2.Update
  66.  
  67. Dim strSQL1 As String
  68. Dim rptID1 As String
  69.  
  70. strSQL1 = "Select Max([PtID]) as [MaxOfID] from Profile;"
  71.  
  72.   Set rst3 = CurrentDb.OpenRecordset(strSQL1)
  73.   rst3.MoveFirst
  74.  
  75.   rptID1 = rst3![MaxOfID]
  76.  
  77. DoCmd.SetWarnings (WarningsOn)
  78.  
  79. DoCmd.OpenForm "Profile", acNormal, , "[PtID]= " & rptID1, acFormEdit, acWindowNormal
  80.  
  81. rst2.Close
  82. rst3.Close
  83.  
  84. DoCmd.Close acForm, "FindPatient", acSaveYes
  85.  
  86. Else
  87. 'Do Nothing
  88.  
  89. End If
  90.  
  91.  
  92. ElseIf rst1.RecordCount = 1 Then
  93.  
  94. Dim strSQL2 As String
  95.  
  96. strSQL2 = "SELECT Profile.PtID As PatientID " & _
  97.          "FROM Profile " & _
  98.          "WHERE Profile.HospitalNumber" & strHospitalNumber & _
  99.          "AND Profile.LastName" & strLastName & _
  100.          "AND Profile.FirstName" & strFirstName & _
  101.          "AND Profile.DOB" & strDOB & _
  102.          "ORDER BY Profile.PtID;"
  103.  
  104. Set rst4 = CurrentDb.OpenRecordset(strSQL2)
  105.  
  106. rst4.MoveFirst
  107.  
  108. Dim RptID2 As String
  109.  
  110. RptID2 = rst4![PatientID]
  111.  
  112. DoCmd.OpenForm "Profile", acNormal, , "[PtID]= " & RptID2, acFormEdit, acWindowNormal
  113.  
  114. DoCmd.Close acForm, "FindPatient", acSaveYes
  115.  
  116. rst1.Close
  117. rst4.Close
  118.  
  119.  
  120. Else
  121.  
  122. Dim Msg2, Style2, Title2, Response2
  123.  
  124. Msg2 = "There are more than 1 records matching these criteria. If you would like to browse these, click 'Yes'. If you would like to enter more criteria, click 'No'."
  125. Style2 = vbYesNo + vbDefaultButton2
  126. Title2 = "Would you like to browse all matching records?"
  127. Response2 = MsgBox(Msg2, Style2, Title2)
  128.  
  129. If Response2 = vbYes Then
  130.  
  131. DoCmd.OpenForm "Profile", acNormal, strSQL0, acFormEdit
  132. 'corresponding to rst1
  133.  
  134. DoCmd.Close acForm, "FindPatient", acSaveYes
  135.  
  136. Else
  137. 'Do Nothing
  138.  
  139. End If
  140.  
  141. rst1.Close
  142.  
  143. End If
  144.  
  145.  
  146. End Sub
Nov 13 '13 #1
0 875

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

Similar topics

1
2990
by: Frogbčrt | last post by:
Config: Win2K, IIS5.0 My solution requires that the host header sent to IIS be analyzed. I have set up a web site that responds to both www.domain.com and domain.com. In DNS, both a WWW and a *...
3
3427
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
14
2453
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
5
4159
by: HydroSan | last post by:
Having a bit of a problem getting UPDATE working. The project in question is a simple MySQL VB.NET frontend, allowing Insertion, Selection, and others. Well, I've gotten Drop and Insert working,...
0
961
by: Shane_SDE | last post by:
I am attempting to use a FormView control with an ObjectDataSource. I have the Select and Update working correctly. I tried to add a Delete Command to either the Edit or the Item Templates and it...
6
5197
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
2
3082
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
2
11133
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
0
1079
by: Irfan | last post by:
hi, I created a clickonce application and installed it in the client machine. As expected a new shortcut is created in the Start->All Programs and i use that to run the application. When i...
3
4171
by: Larry Hale | last post by:
Thank you, again, Michael, for all your help many months ago. I *FINALLY* got a HowTo done up; please see http://wiki.python.org/moin/HowTo/FileMagic I've also emailed Mr. Hupp to see if he'll...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
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
7493
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...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.