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

Home Posts Topics Members FAQ

"Unrecognized database format" error happening once a day

10 New Member
Hello,

I currently have a split db and I keep getting this error after about a day's worth of use. Once I've repaired it, I have created a clean db, imported the tables from a previous backup and everything works with no issues, until the next day when it gets corrupted again. I thought at first it was a bad form. so I rebuilt it.

Can u look at the code on this form?

What this form does is it inserts data from end-users (who have the FE on their desktops) for channel issues. If there is 3 instances of the channel number in the same market it will send an email to a supvervisor informing of possible issues. Any more instances of that same channel in the market, will pop up a msg saying we have enough issues and close out.

In this same form there is also a "clear channel outage" button, which is used once said channel issue in market has been resolved, so if there is another instance of that channel in that market then the end-user can submit it again (as it maybe another issue, not related to the 'cleared" one)

In the code of that form, am I not exiting the application gracefully? I use LDB Viewer and when the app exits, it says I exited the app but I'm leaving the DB in a possible "suspect" state...anyway to avoid that?

Here is the code for that form...
------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Private Sub FldCustName_LostFocus()
  3.  
  4. If IsNull(Forms![frmLeadChannelForm]![FldCustName]) Then
  5. MsgBox "You must enter the customer's name!", vbCritical
  6.  
  7. End If
  8.  
  9. End Sub
  10. Private Sub FldAcctNumb_LostFocus()
  11. If IsNull(Forms![frmLeadChannelForm]![FldAcctNumb]) Then
  12. MsgBox "You must enter the 16 digit account number!", vbCritical
  13.  
  14. End If
  15. End Sub
  16.  
  17.  
  18.  
  19. Private Sub FldAddress_LostFocus()
  20. If IsNull(Forms![frmLeadChannelForm]![FldAddress]) Then
  21. MsgBox "You must enter the customer's address!", vbCritical
  22. End If
  23.  
  24. End Sub
  25. Private Sub FldPhoneNumb_LostFocus()
  26. If IsNull(Forms![frmLeadChannelForm]![FldPhoneNumb]) Then
  27. MsgBox "You must enter the customer's main phone number!", vbCritical
  28. End If
  29.  
  30. End Sub
  31.  
  32.  
  33. Private Sub ClearChannel_Click()
  34. DoCmd.SetWarnings False
  35.  
  36. Dim ClearChannel As String
  37. ClearChannel = "UPDATE TBLMaster SET TBLMaster.FldCleared = 'yes'"
  38. ClearChannel = ClearChannel & " WHERE (([TBLMaster]![FldMarket]=[Forms]![frmLeadChannelForm]![fldMarket] And [TBLMaster]![FldChannelNumb]=[Forms]![frmLeadChannelForm]![FldChannelNumb]));"
  39.  
  40. DoCmd.RunSQL (ClearChannel)
  41. DoCmd.SetWarnings True
  42.  
  43. MsgBox " Channel " & Me.FldChannelNumb & vbCrLf & "Market Affected: " & Me.FldMarket & vbCrLf & vbCrLf & " OUTAGE CLEARED!", vbOKOnly
  44.  
  45. End Sub
  46.  
  47. 'Private Sub FldChannelNumb_AfterUpdate()
  48.  
  49. 'Finish1
  50.  
  51. 'Dim Value2 As Variant
  52. 'Value2 = DLookup("[CountOfChannelProblem]", "TblChannelCount", "[FldMarket]='" & Forms![frmLeadChannelForm]![FldMarket] & "' And [FldChannelNumb]='" & Forms![frmLeadChannelForm]![FldChannelNumb] & "' AND [CountOfChannelProblem]>=3")
  53. 'If Value2 >= 3 Then
  54. 'MsgBox "We have enough examples of this issue! Please inform customer.", vbOKOnly & vbExclamation, "Known Issue!"
  55. 'Finish3
  56. 'Application.Quit
  57. 'ElseIf Value < 3 Then
  58. 'Finish3
  59. 'End If
  60.  
  61. 'End Sub
  62.  
  63.  
  64. Private Sub Form_Open(Cancel As Integer)
  65. DoCmd.GoToRecord , , acNewRec
  66. End Sub
  67. Private Sub btnCheckFinish_Click()
  68. On Error GoTo Err_btnCheckFinish_Click
  69.  
  70. If IsNull(Forms![frmLeadChannelForm]![FldAcctNumb]) Then
  71. MsgBox "You must enter the customer's name!", vbCritical
  72. Exit Sub
  73.  
  74. ElseIf IsNull(Forms![frmLeadChannelForm]![FldCustName]) Then
  75. MsgBox "You must enter the 16 digit account number!", vbCritical
  76. Exit Sub
  77.  
  78. ElseIf IsNull(Forms![frmLeadChannelForm]![FldAddress]) Then
  79. MsgBox "You must enter the customer's address!", vbCritical
  80. Exit Sub
  81.  
  82. ElseIf IsNull(Forms![frmLeadChannelForm]![FldPhoneNumb]) Then
  83. MsgBox "You must enter the customer's main phone number!", vbCritical
  84. Exit Sub
  85. End If
  86.  
  87. SysCmd acSysCmdInitMeter, "Processing...", 10
  88. Finish1
  89. SysCmd acSysCmdUpdateMeter, 5
  90. Finish2
  91. Finish3
  92. SysCmd acSysCmdUpdateMeter, 10
  93. SysCmd acSysCmdRemoveMeter
  94. DoCmd.Quit
  95. Exit_btnCheckFinish_Click:
  96. Exit Sub
  97.  
  98. Err_btnCheckFinish_Click:
  99. MsgBox Err.Description
  100. Resume Exit_btnCheckFinish_Click
  101.  
  102. End Sub
  103.  
  104. Private Sub Finish1()
  105. Me.Dirty = False
  106.  
  107. Dim UpdateDB As String
  108. UpdateDB = "UPDATE TblMaster, TblMarket SET TblMaster.FldMarket = TblMarket!FldMarket"
  109. UpdateDB = UpdateDB & " WHERE ((TblMarket!FldSysprin=Left(TblMaster!FldAcctNumb,6)));"
  110.  
  111.  
  112. Dim MakeTable As String
  113. MakeTable = "SELECT TBLMaster.FldChannelNumb, TBLMaster.FldMarket, Count(TBLMaster.FldChannelNumb) AS CountOfFldChannelName, Count(TBLMaster.FldMarket) AS CountOfChannelProblem INTO TblChannelCount"
  114. MakeTable = MakeTable & " FROM TBLMaster WHERE (((TBLMaster.FldChannelNumb) Is Not Null) AND (TBLMaster.FldDate)=Date() AND (TBLMaster.FldCleared) Is Null)"
  115. MakeTable = MakeTable & " GROUP BY TBLMaster.FldChannelNumb, TBLMaster.FldMarket;"
  116.  
  117. DBEngine(0)(0).Execute (MakeTable)
  118. DBEngine(0)(0).Execute (UpdateDB)
  119.  
  120. End Sub
  121.  
  122. Private Sub Finish2()
  123.  
  124. Dim Value As Variant
  125. Value = DLookup("[CountOfChannelProblem]", "TblChannelCount", "[FldMarket]='" & Forms![frmLeadChannelForm]![FldMarket] & "' And [FldChannelNumb]='" & Forms![frmLeadChannelForm]![FldChannelNumb] & "' And [CountOfChannelProblem]=2")
  126. If Value = 2 Then
  127. DoCmd.SendObject acSendReport, "rptAutoChannel2", acFormatXLS, "xxx@xxx.com", , "xxx@xxx.com; xxx@xxx.com", "****TESTING AutoOutage Report TESTING****" & "Channel " & Me.FldChannelNumb & " / " & Me.FldMarket, "Please see the attached report for issue details. TS3000 Development Team", 0
  128. MsgBox "This issue has been sent for DNOC and Lead/Supervisor follow-up.", vbExclamation, "Notification Sent!"
  129.  
  130. End If
  131. End Sub
  132.  
  133. Private Sub Finish3()
  134.  
  135. DoCmd.RunSQL ("Drop Table TblChannelCount")
  136. End Sub

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

Thanks,

Clarence
Aug 22 '07 #1
13 2387
puppydogbuddy
1,923 Recognized Expert Top Contributor
Clarence,

One thing I would definitely do is test my code with the warnings turned on during testing and see just what kinds of warnings you are getting:

Secondly, I took a quick "rough" look at your code and saw two things that look problematic.

1. Your use of the LossFocus event for validation. Generally validation is done in the Form_BeforeUpdate event, which is the event that occurs just before any data is saved. Using the lostFocus event does not guarantee that the controls you want filled will be filled.....>>>>>>simply said, if a control never gets the focus, the lostfocus event will never fire for that control,.and if some of the controls cause an error if they are not filled....that could be a source for corruption<<<<<<< In addition, the before update event can be canceled for legitimate reasons ....like the person has to look up some information before entering. See this link for a step by step "howTo" do data validation using the beforeUpdate event of the Form.

http://www.databasedev.co.uk/validate_textbox.html

2. the second thing that looks potentially problematic is this line:

ClearChannel = "UPDATE TBLMaster SET TBLMaster.FldCleared = 'yes'"

Genrally yes/no fields are declared as a boolean data type; if FldCleared is defined as boolean in your table, then setting equal to the string "Yes" is incorrect...it should be set to Boolean True or False. Consequently, it is possible that your update statement is causing the corruption.


Hope this helps.
Aug 22 '07 #2
clarencemo
10 New Member
Puppy,

If I removed the LostFocus code from there and just do the validation at btnCheckFinish...would that be better??

The issue I run into with using the vaidation code that u are suggesting is that after I do the btnCheckFinish, if no data is present in the field I'm validating, It'll pop up the "data needed" box and then give me a msg that says "No current record" and puts me back to the form. How can I get it where it gives me the validation message, give focus back to the form and won't continue the btnCheckFinish sub.

Thanks,

Clarence



Clarence,

One thing I would definitely do is test my code with the warnings turned on during testing and see just what kinds of warnings you are getting:

Secondly, I took a quick "rough" look at your code and saw two things that look problematic.

1. Your use of the LossFocus event for validation. Generally validation is done in the Form_BeforeUpdate event, which is the event that occurs just before any data is saved. Using the lostFocus event does not guarantee that the controls you want filled will be filled.....>>>>>>simply said, if a control never gets the focus, the lostfocus event will never fire for that control,.and if some of the controls cause an error if they are not filled....that could be a source for corruption<<<<<<< In addition, the before update event can be canceled for legitimate reasons ....like the person has to look up some information before entering. See this link for a step by step "howTo" do data validation using the beforeUpdate event of the Form.

http://www.databasedev.co.uk/validate_textbox.html

2. the second thing that looks potentially problematic is this line:

ClearChannel = "UPDATE TBLMaster SET TBLMaster.FldCleared = 'yes'"

Genrally yes/no fields are declared as a boolean data type; if FldCleared is defined as boolean in your table, then setting equal to the string "Yes" is incorrect...it should be set to Boolean True or False. Consequently, it is possible that your update statement is causing the corruption.


Hope this helps.
Aug 22 '07 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
Clarence,
I have a better idea. Create a Form_BeforeUpdate proc that calls (and re-executes) your lostFocus subs (as shown below). That way you can leave your lostFocus events as they are, except for modifications to the error message, which is also show below. Executing the Form_BeforeUpdate event in this way will act as a safety net for any validation errors not captured and/or corrected via your lostFocus event procedures, while piggybacking on corrections already made that no longer require correction.

The before update will concatenate each of the validation failure messages returned by the lostFocus subs and will advise the user with a single message box for all the remaining errors, with each message having its own row in the message box. The return value will cancel the update if any validation returns an error string and the user will be prevented from leaving the record. This is a necessary evil in order to force correction on any critical items. So, if the missing info that you are trying to trap in the lostFocus events is not critical to the integrity of your database, don’t call the lostFocus event for that item in your Form_beforeUpdate proc. This way you will have the best of both worlds, so to speak.


In the general declarations section, Dim a strMsg for each one of your messages in the lost focus events:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Dim strMsg1 As String
  5. Dim strMsg2 As String
  6. Dim strMsg3 As String
  7. Dim strMsg4 As String
  8.  
  9. initialize the strMsg variables:
  10. strMsg1 = "You must enter the customer's name!"
  11. strMsg2 = "You must enter the 16 digit account number!"
  12. strMsg3 = "You must enter the customer's address!"  
  13. strMsg4 = "You must enter the customer's main phone number!"
  14.  
  15. 2. In your Lost Focus 
  16.  
  17. Private Sub FldCustName_LostFocus()
  18.      If IsNull(Forms![frmLeadChannelForm]![FldCustName]) Then
  19.                MsgBox strMsg1, vbCritical
  20.     End If
  21. End Sub
  22.  
  23. Private Sub FldAcctNumb_LostFocus()
  24.      If IsNull(Forms![frmLeadChannelForm]![FldAcctNumb]) Then
  25.               MsgBox strMsg2 , vbCritical
  26.      End If
  27. End Sub
  28.  
  29. Private Sub FldAddress_LostFocus()
  30.      If IsNull(Forms![frmLeadChannelForm]![FldAddress]) Then
  31.               MsgBox strMsg3, vbCritical
  32.      End If
  33. End Sub
  34.  
  35. Private Sub FldPhoneNumb_LostFocus()
  36.       If IsNull(Forms![frmLeadChannelForm]![FldPhoneNumb]) Then
  37.                MsgBox strMsg4 , vbCritical
  38.        End If
  39. End Sub
  40.  
  41. Here is the Form_BeforeUpdate procedure:
  42.  
  43. Private Sub Form_BeforeUpdate(Cancel As Integer) 
  44. Dim strMsg As String          ‘consolidates individual messages into one string
  45. Dim x As Integer                 ‘ message subscript
  46.  
  47.  ‘call and re-execute lostFocus validation procedure as final check
  48.       FldCustName_LostFocus
  49.     FldAcctNumb_LostFocus
  50.     FldAddress_LostFocus
  51.     FldPhoneNumb_LostFocus
  52.  
  53. For x = 1 to 4
  54.  strMsg = strMsg & (strMsg & x) 
  55. Next x
  56.  
  57. If Len(strMsg & "")  <> "" Then
  58.          Cancel = True
  59.          MsgBox strMsg
  60. End If
  61. End Sub
Aug 22 '07 #4
clarencemo
10 New Member
Puppy,

U rock...I will try that...

In response to your message about possible code driven corruption routines,

How do I change this sub to instead update the fldMarket during data entry instead of the following code, which updates the whole table?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Finish1()
  2.  
  3.     Me.Dirty = False
  4.  
  5. Dim UpdateDB As String
  6.     UpdateDB = "UPDATE TblMaster, TblMarket SET TblMaster.FldMarket = TblMarket!FldMarket"
  7.     UpdateDB = UpdateDB & " WHERE ((TblMarket!FldSysprin=Left(TblMaster!FldAcctNumb,6)));"
  8.  
  9.  
  10. Dim MakeTable As String
  11.     MakeTable = "SELECT TBLMaster.FldChannelNumb, TBLMaster.FldMarket, Count(TBLMaster.FldChannelNumb) AS CountOfFldChannelName, Count(TBLMaster.FldMarket) AS CountOfChannelProblem INTO TblChannelCount"
  12.     MakeTable = MakeTable & " FROM TBLMaster WHERE (((TBLMaster.FldChannelNumb) Is Not Null) AND (TBLMaster.FldDate)=Date() AND (TBLMaster.FldCleared) Is Null)"
  13.     MakeTable = MakeTable & " GROUP BY TBLMaster.FldChannelNumb, TBLMaster.FldMarket;"
  14.  
  15. DBEngine(0)(0).Execute (MakeTable)
  16. DBEngine(0)(0).Execute (UpdateDB)
  17.  
  18. End Sub
Aug 22 '07 #5
puppydogbuddy
1,923 Recognized Expert Top Contributor
I found some errors in my previous, made the corrections here:

Clarence,
I have a better idea. Create a Form_BeforeUpdate proc that calls (and re-executes) your lostFocus subs (as shown below). That way you can leave your lostFocus events as they are, except for modifications to the error message, which is also show below. Executing the Form_BeforeUpdate event in this way will act as a safety net for any validation errors not captured and/or corrected via your lostFocus event procedures, while piggybacking on corrections already made that no longer require correction.

The before update will concatenate each of the validation failure messages returned by the lostFocus subs and will advise the user with a single message box for all the remaining errors, with each message having its own row in the message box. The return value will cancel the update if any validation returns an error string and the user will be prevented from leaving the record. This is a necessary evil in order to force correction on any critical items. So, if the missing info that you are trying to trap in the lostFocus events is not critical to the integrity of your database, don’t call the lostFocus event for that item in your Form_beforeUpdate proc. This way you will have the best of both worlds, so to speak.


In the general declarations section, Dim a strMsg for each one of your messages in the lost focus events:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Dim strMsg As String
  5. Dim strMsg1 As String
  6. Dim strMsg2 As String
  7. Dim strMsg3 As String
  8. Dim strMsg4 As String
  9.  
  10. initialize the strMsg variables:
  11. strMsg = “”
  12. strMsg1 = "You must enter the customer's name!"
  13. strMsg2 = "You must enter the 16 digit account number!"
  14. strMsg3 = "You must enter the customer's address!"  
  15. strMsg4 = "You must enter the customer's main phone number!"
  16.  
  17. 2. In your Lost Focus 
  18.  
  19. Private Sub FldCustName_LostFocus()
  20.      If IsNull(Forms![frmLeadChannelForm]![FldCustName]) Then
  21.             strMsg = strMsg1   
  22. MsgBox strMsg, vbCritical
  23.     End If
  24. End Sub
  25.  
  26. Private Sub FldAcctNumb_LostFocus()
  27.      If IsNull(Forms![frmLeadChannelForm]![FldAcctNumb]) Then
  28.       strMsg = strMsg2   
  29.            MsgBox strMsg , vbCritical
  30.      End If
  31. End Sub
  32.  
  33. Private Sub FldAddress_LostFocus()
  34.      If IsNull(Forms![frmLeadChannelForm]![FldAddress]) Then
  35.             strMsg = strMsg3  
  36. MsgBox strMsg, vbCritical
  37.      End If
  38. End Sub
  39.  
  40. Private Sub FldPhoneNumb_LostFocus()
  41.       If IsNull(Forms![frmLeadChannelForm]![FldPhoneNumb]) Then
  42.             strMsg = strMsg4   
  43. MsgBox strMsg , vbCritical
  44.        End If
  45. End Sub
  46.  
  47. Here is the Form_BeforeUpdate procedure:
  48.  
  49. Private Sub Form_BeforeUpdate(Cancel As Integer) 
  50.  
  51. Dim x As Integer                 ‘ message subscript
  52.  
  53. strMsg = “”
  54.  ‘call and re-execute lostFocus validation procedure as final check
  55.       FldCustName_LostFocus
  56.     strMsg1 = strMsg
  57.     FldAcctNumb_LostFocus
  58.     strMsg2 = strMsg
  59. FldAddress_LostFocus
  60. strMsg3 = strMsg
  61.     FldPhoneNumb_LostFocus
  62.     strMsg4 = strMsg
  63. strMsg = “”
  64. For x = 1 to 4
  65.  strMsg = strMsg & (strMsg & x) 
  66. Next x
  67.  
  68. If Len(strMsg & "")  <> “” Then
  69.          Cancel = True
  70.          MsgBox strMsg
  71. End If
  72. End Sub
Aug 23 '07 #6
clarencemo
10 New Member
Now I tried that way u suggested and it gives me the error:

Compile error - Invalid Outside Procedure

--------------------------
Aug 23 '07 #7
puppydogbuddy
1,923 Recognized Expert Top Contributor
Now I tried that way u suggested and it gives me the error:

Compile error - Invalid Outside Procedure

--------------------------
Clarence,
The lines you need to correct are shown below. LInes 10, 17, 47, 51 (starting with message subscript), and 54 are not code and should be commented out. Lines 11, 53, 63 , and 68 should contain standard double quotes instead strange looking double quotes shown. For some reason, when I copy and paste, the single and double quote characters are not coming out quite right. Standard double quotes should look like this: " , 2 double quotes should look like this: "" not like this: “”. After you fix, run it again.. If there are errors, try to at least locate the error line and provide as much detail about the error message as you can..

Line 10 initialize the strMsg variables:
Line 11 strMsg = “”
Line 17 2. In your Lost Focus
Line 47 Here is the Form_BeforeUpdate procedure:
Line 51 ‘ message subscript
Line 53 strMsg = “”
Line 54 ‘call and re-execute lostFocus validation procedure as final check
Line 63 strMsg = “”
Line 68 If Len(strMsg & "") <> “” Then
Aug 23 '07 #8
clarencemo
10 New Member
Puppy,

Great looking out on the code...works great.

Now u said that update statement is a little leery so, can u help me clean up this sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub Finish1()
  2.     Me.Dirty = False
  3.  
  4. Dim UpdateDB As String
  5.     UpdateDB = "UPDATE TblMaster, TblMarket SET TblMaster.FldMarket = TblMarket!FldMarket"
  6.     UpdateDB = UpdateDB & " WHERE ((TblMarket!FldSysprin=Left(TblMaster!FldAcctNumb,6)));"
  7.  
  8.  
  9. Dim MakeTable As String
  10.     MakeTable = "SELECT TBLMaster.FldChannelNumb, TBLMaster.FldMarket, Count(TBLMaster.FldChannelNumb) AS CountOfFldChannelName, Count(TBLMaster.FldMarket) AS CountOfChannelProblem INTO TblChannelCount"
  11.     MakeTable = MakeTable & " FROM TBLMaster WHERE (((TBLMaster.FldChannelNumb) Is Not Null) AND (TBLMaster.FldDate)=Date() AND (TBLMaster.FldCleared) Is Null)"
  12.     MakeTable = MakeTable & " GROUP BY TBLMaster.FldChannelNumb, TBLMaster.FldMarket;"
  13.  
  14. DBEngine(0)(0).Execute (MakeTable)
  15. DBEngine(0)(0).Execute (UpdateDB)
  16.  
  17. End Sub
It would be Ideal from a processing standpoint to instead do the update before the click. It currently works "on click" where it updates the whole tblMaster table. Can u help me change the code where it would update the field called fldMarket in tblMaster after focus is lost on the fldAcctNumb text box

fldMarket is based populated based on a table called tblMarket where the 1st 6 digits (fldSysPrin) of the 16 digit acct number = the market name (fldMarket)

example:

123456 = Denver, CO
789456 = Vail, CO

so if someone enters an account number of 1234560000000000 then the field called fldMarket in the tblMaster would be populated with Denver, CO upon lost focus of fldAcctNumb

Thanks for all your help,

Clarence
Aug 23 '07 #9
puppydogbuddy
1,923 Recognized Expert Top Contributor
Puppy,

Great looking out on the code...works great.

Now u said that update statement is a little leery so, can u help me clean up this sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub Finish1()
  2.     Me.Dirty = False
  3.  
  4. Dim UpdateDB As String
  5.     UpdateDB = "UPDATE TblMaster, TblMarket SET TblMaster.FldMarket = TblMarket!FldMarket"
  6.     UpdateDB = UpdateDB & " WHERE ((TblMarket!FldSysprin=Left(TblMaster!FldAcctNumb,6)));"
  7.  
  8.  
  9. Dim MakeTable As String
  10.     MakeTable = "SELECT TBLMaster.FldChannelNumb, TBLMaster.FldMarket, Count(TBLMaster.FldChannelNumb) AS CountOfFldChannelName, Count(TBLMaster.FldMarket) AS CountOfChannelProblem INTO TblChannelCount"
  11.     MakeTable = MakeTable & " FROM TBLMaster WHERE (((TBLMaster.FldChannelNumb) Is Not Null) AND (TBLMaster.FldDate)=Date() AND (TBLMaster.FldCleared) Is Null)"
  12.     MakeTable = MakeTable & " GROUP BY TBLMaster.FldChannelNumb, TBLMaster.FldMarket;"
  13.  
  14. DBEngine(0)(0).Execute (MakeTable)
  15. DBEngine(0)(0).Execute (UpdateDB)
  16.  
  17. End Sub
It would be Ideal from a processing standpoint to instead do the update before the click. It currently works "on click" where it updates the whole tblMaster table. Can u help me change the code where it would update the field called fldMarket in tblMaster after focus is lost on the fldAcctNumb text box

fldMarket is based populated based on a table called tblMarket where the 1st 6 digits (fldSysPrin) of the 16 digit acct number = the market name (fldMarket)

example:

123456 = Denver, CO
789456 = Vail, CO

so if someone enters an account number of 1234560000000000 then the field called fldMarket in the tblMaster would be populated with Denver, CO upon lost focus of fldAcctNumb

Thanks for all your help,

Clarence

Hi Clarence,

Glad the code worked out for you.

In reference to your request above, what you want can be accomplished several ways, but I need more information from you, before pursuing..

Is your form bound or unbound (with respect to the table)? If your form is bound, you can move the update of fldMarket via the Form in one of two ways.

1. by means of users selecting the fldMarket from dropdown list whose rowSource would be your table.
2. by means of a Dlookup directly to the table based on your criteria

In either case above. I would recommend that you use the AfterUpdate (vs the lostFocus) of the control fldAcctNum on your form to trigger the update of fldMarket.

Let me know what you think.


Puppy
Aug 23 '07 #10
clarencemo
10 New Member
The form is bound to the tblMaster, however the first field is a UNBOUND field with a label called "Select Market", all other fields are bound to tblMaster

the Select market field is just used to determine how many instances of the same channel and same market have occurred

So I would like the acct number fisrt 6 to determine the market based on that table I told u about earlier

I think Dlookup would work better...as I'm trying to update the "dirty" record on the fly instead of having to update the whole table

Thanks again,

Clarence
Aug 23 '07 #11
puppydogbuddy
1,923 Recognized Expert Top Contributor
The form is bound to the tblMaster, however the first field is a UNBOUND field with a label called "Select Market", all other fields are bound to tblMaster

the Select market field is just used to determine how many instances of the same channel and same market have occurred

So I would like the acct number fisrt 6 to determine the market based on that table I told u about earlier

I think Dlookup would work better...as I'm trying to update the "dirty" record on the fly instead of having to update the whole table

Thanks again,

Clarence
Ok, Clarence. Try the following code in place of your applicable code. I think you should change the name property of the effected textboxes on your form to eliminate ambiiguity between the control name and the name of the control source, which is the field. So, as per naming conventions txtAcctNumb and txtMarket refer to the textbox controls on the form and fldAcctNumb and fldMarket refer to the control source of the textboxes, which are the fields in the table.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtAcctNumb_AfterUpdate()
  2.  
  3. If Not IsNull(Me![txtAcctNumb]) Then
    Me![txtMarket].Value = DLooKup("[fldMarket]", "tblMarket", "[fldSysPrin] = " & Left(Me![txtAcctNumb],6) 
    End If 
  4. End Sub
  5.  

The above syntax assumes fldSysPrin is a numeric data type. If it is a text data type, the syntax would be like this:
Me![txtMarket].Value = DLooKup("[fldMarket]", "tblMarket", "[fldSysPrin] = '" & Left(Me![txtAcctNumb],6) & "'"
Aug 24 '07 #12
clarencemo
10 New Member
Puppy,

That code works great...thanks for all your help this week...have a great weekend

Thanks,

Clarence
Aug 24 '07 #13
puppydogbuddy
1,923 Recognized Expert Top Contributor
Puppy,

That code works great...thanks for all your help this week...have a great weekend

Thanks,

Clarence
Clarence,
You are most welcome. I hope the new code solved your problem with the database corruption. Let me know if the database is still stable after a week or so.

Puppy
Aug 25 '07 #14

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

Similar topics

1
6243
by: Ixnay | last post by:
Hello All, I know this issue has be addressed a gazillion times in the past, but none of the offered solutions seem to work for me. I get this error when I attempt to pull down the...
3
6164
by: Noah | last post by:
How does Image.putdata() work? I am using PIL 1.1.3. This simple script throws an exception on putdata(): import Image width = 10 height = 10 im = Image.new ("RGB", (width, height)) L =...
7
26756
by: qbsu21th | last post by:
Dear Sir/Madam, I'm writing a small VB6.0 and Access 2002 application in XP OS. I selected the data control property RecordSource, I got the "Unrecognized database format 'xxx/xx/*.mdb' " error....
13
4303
by: - Steve - | last post by:
I've been given a school assignment and while everything else is easy there's one topic I'm completley lost on. I've been given an ASCII file that looks like this. During start-up, the program...
1
6179
by: Trygve Lorentzen | last post by:
Hi, my webservice is running on Win2000 SP4, IIS 5.0 fully patched, connecting to a MySQL database and mainly returning Typed DataSet's from webmethods. After running for a while, generally a...
3
1886
by: Joanne | last post by:
I have searched through previous threads regarding this error. I went back through all my code to make sure I closed and set to nothing all open db's and rs's. However, I still have one computer...
8
2726
by: situ | last post by:
Hello all, i have Database1 and database2, is it possible to make database connection to database2 by running stored procedure on database1. Thanks and Regards Situ
1
12574
by: Pradeep83 | last post by:
Hi All, Good Morning Here I am jotdowning my problem I am compiling a .c file in Free BSD 6.0 and exceuting there itself. and i have taken that...
4
17998
by: Hepburn08 | last post by:
Hi, I need some help opening a corrupt Microsoft Access database file. I get an error message that says "unrecognized database format". Since I can't open it, I can't export the data to another new...
0
7114
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
7321
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
7377
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...
0
7488
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
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
412
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.