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

SQL to return updateable records

I am using an SQL statement in a forms record source. This statement distinguishes between departments and returns all the records for that department. The problem is the forms main intention is to allow users to enter new records into the database. This worked before I used the SQL statement simply by the user pressing the >* button, but this button is now not pressable.

Here is my SQL statement

[code]... SELECT * FROM Supervisor, UserInfo WHERE (((UserInfo.DeptID)=+2)) And Supervisor.ID=UserInfo.ID..[code]

I have tried an insert statement but cannot seem to get this to work...Any help would be appreciated. Thanks
Sep 6 '06 #1
5 1466
Oh yeah here is the vb code for this app

Expand|Select|Wrap|Line Numbers
  1. ....Const ReplString = "+2"
  2.     Dim intInsPt As Integer, strUserMatch As Variant
  3.  
  4.     intInsPt = InStr(Me.RecordSource, ReplString)
  5.     If intInsPt = 0 Then
  6.         ' Oops! SQL template has no ReplString in it!
  7.         Beep
  8.         MsgBox "Form Record Source error. Notify programmer.", vbExclamation
  9.         Cancel = True
  10.         Exit Sub
  11.     End If
  12.     strUserMatch = DLookup("UserInfo.DeptID", _
  13.         "UserInfo", "UserName='" & CurrentUser() & "'")
  14.  
  15.     If IsNull(strUserMatch) Then
  16.         ' Oops! No match for user in UserInfo table
  17.         Beep
  18.         MsgBox "No permission found for " & CurrentUser() _
  19.             & ". Notify programmer.", vbExclamation
  20.         Cancel = True
  21.         Exit Sub
  22.     End If
  23.     ' Now modify the form record source to select
  24.     ' records for this user only
  25.     Me.RecordSource = Left$(Me.RecordSource, intInsPt - 1) _
  26.         & strUserMatch _
  27.         & Mid$(Me.RecordSource, intInsPt + Len(ReplString))
  28.  
  29.  
Sep 6 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Your form is probably based on a query which is not updateable. I would suggest that you create a new form with the purpose of entering data only. You can have it open on a button click event on this form. Tie it to the table or query it used to be tied to. Make sure the forms data entry property is set to yes.



I am using an SQL statement in a forms record source. This statement distinguishes between departments and returns all the records for that department. The problem is the forms main intention is to allow users to enter new records into the database. This worked before I used the SQL statement simply by the user pressing the >* button, but this button is now not pressable.

Here is my SQL statement

[code]... SELECT * FROM Supervisor, UserInfo WHERE (((UserInfo.DeptID)=+2)) And Supervisor.ID=UserInfo.ID..[code]

I have tried an insert statement but cannot seem to get this to work...Any help would be appreciated. Thanks
Sep 6 '06 #3
I was thinking that too...I still would not like for the dept to see each others data though and that would be the case with this.... Right? or is there a way to not have any records shown only a blank form that you can input into?
Sep 6 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Changing the Data Entry option to Yes will only show a new record. No other records will be visible.



I was thinking that too...I still would not like for the dept to see each others data though and that would be the case with this.... Right? or is there a way to not have any records shown only a blank form that you can input into?
Sep 6 '06 #5
Thanks, I'm heading in a whole different direction now
Sep 6 '06 #6

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

Similar topics

7
by: ren | last post by:
Hello, When I open with Access 2000 a .DBF table and try to modify the content of a (random) record, I get the message 'This recordset is not updateable". And indeed, I can't change the content...
3
by: jm | last post by:
I have a simple query. It has two tables. If I open the tables separately, I can add records. If I open them up together, the recordset is not updateable. As best I know, this has never been a...
5
by: Marie | last post by:
Access97 I have a table containing addresses with a separate field for State. Is there a way to create a query that returns an unique list of the states in that table and still be updateable? I...
5
by: Jack | last post by:
TblProduct ProductID ProductName Selected (Y/N) TblOrder OrderID CustomerID TblOrderDetail
3
by: dd_bdlm | last post by:
Please help this one is driving me mad! I have searched and read all the topics on the error message I am receiving but none seem to apply to me! I have quite a complex query linking all parts...
7
by: Stephen Poley | last post by:
I have the following situation: - a table of employees, keyed on employee-id; - a table of training sessions, keyed on session-id; - a requirement to log who was present at which session, plus...
2
by: me | last post by:
I have written a query that joins four or five tables. One table has 30,000 rows. Another table has only 200. I want to only return the 200 or so rows in the smaller table and columns from the...
4
by: Mike D | last post by:
OS: Windows XP Professional Microsoft Access 2003 I am trying to update a table in my DB from a tempory table. I need to ensure that if records in the main table match records in the temp...
2
by: jghouse | last post by:
Everyone, Hopefully you can help me with a little problem I am having. I have a need to limit the records shown in a form by a few different criteria. I also need these records to be editable....
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: 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
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
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
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
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,...

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.