Search results

  1. S

    VBA SQL Select statement based on content in a text box

    Still having a couple of issues with this. The All employees works fine, its just the current user which prompts for sFormUser when it should get it from the form - any ideas? Dim sProjectRef As String Dim sTotalhours As String Dim MySQL As String Dim sGroupID As Integer Dim sUserID As String...
  2. S

    VBA SQL Select statement based on content in a text box

    I dont suppose you can help with this please ..... Im trying to get it so if the combo is blank or there is no data in the text box it errors, but at the moment its just going around in a loop : Private Sub TotalHoursOk_btn_Click() Dim MySQL As String Dim sGroupID As Integer Dim sUserID As...
  3. S

    VBA SQL Select statement based on content in a text box

    Solved - put quotes around the sUserID to read sUserID = "Forms![TimesheetForm]![LoggedInUser]" And ot works fine now.... Not too sure why :confused:
  4. S

    VBA SQL Select statement based on content in a text box

    Hmmm its still causing issues. Its not using the sUserID which is the LoggedInUser to lookup the value for the sGroupID from the table. Its referencing the sUserID Dim MySQL As String Dim sGroupID As Integer Dim sUserID As String sUserID = Forms![TimesheetForm]![LoggedInUser] sGroupID =...
  5. S

    VBA SQL Select statement based on content in a text box

    Hi guys, Im still having a few issues with this, as per the code below Im getting the error " You entered an invalid argument in a domain aggregate function". So I have used the Immediate window to query what sGroupID is and its returning 0 but its 2 in the table. I even changed the DLookup...
  6. S

    VBA SQL Select statement based on content in a text box

    Just so I have got this straight as I might be leading you up the garden path. Is my understanding of this right The sUserID is pulled from the form and stored. The DLookup is then looking for the sUserID in the UserNames_tbl and pulling out the relevant DepGroupID for that user based on the...
  7. S

    VBA SQL Select statement based on content in a text box

    Thanks Ive made those changes, and also Im sure sUserID should be integer as its a stored number as thats what it is in the table? so I have changed that. But now I get error type mismatch :S Option Compare Database Private Sub TotalHoursOk_btn_Click() Dim MySQL As String Dim sGroupID As...
  8. S

    VBA SQL Select statement based on content in a text box

    Cool, thanks worked like a charm. You couldnt help me with this code please? Private Sub TotalHoursOk_btn_Click() Dim MySQL As String Dim sGroupID As String sUser = Forms![TimesheetForm]![LoggedInUser] sGroupID = DLookup(DepGroupID, UserNames_tbl, sUser) If sGroupID = "2" Then MySQL =...
  9. S

    VBA SQL Select statement based on content in a text box

    Thanks for that, works like a treat. Although is there a way I can get it to accept wildcards for the criteria within the text box? For example I have multiple records which start PP190 and then - test, -record, so they would read PP190-test, PP190-record etc but if I do a search with PP190* it...
  10. S

    VBA SQL Select statement based on content in a text box

    Thanks for the quick reply, its not a number its a text field, but I do this I get the error a RunSQL action requires an argument consistsing of an SQL statement. I'll give it an argument in a minute :)
  11. S

    VBA SQL Select statement based on content in a text box

    Ok guys - yep me again. Im bambuzzled as to how VBA and sql statements are supposed to work. It seems you use different command depending on what you are trying to achieve - is this correct? What I am trying to do is query a table based on the input of a textbox. Based on below the error U get...
  12. S

    Querying different table\form from current one

    Is it possible to get dlookup to look within a column as opposed to a specific value within a column? As based on my code above sGroup could equal different values depending on what group the user is in?? Thanks
  13. S

    Querying different table\form from current one

    Hi Im not too sure if this is the best way to go about it so I am definitely open to suggestions. Im trying to reference a column in a table which holds which group a person is in. I am then using select case to tally up if they can run a query. The problem is I cant get VBA to recognize the...
  14. S

    Ignoring commas when users enter data

    Worked like a treat - thanks!
  15. S

    Ignoring commas when users enter data

    Thanks John, I think the fact I am calling the description then trying to change the value is causing me problems as per my code below: sHourType = Me.Hour.Value sCostCode = Me.CostCode sActivity = Me.Activity.Column(0) sProject = Me.Project.Column(2) sHours = Nz(Me.Hour, 0) sDescript =...
  16. S

    Ignoring commas when users enter data

    Hi, Am I correct in thinking the terminology is called parsing? If so.. Then what I am trying to do is when users enter a description into a field they occasionally add commas etc. How do I allow them to enter them? Or do I need to have some method of removing them on submittion? Thanks in...
  17. S

    Controlling access to a form

    Thanks David, I have the getusername function within my database already. The bit I was concerned about (and I think this would be the case regardless) the table holding who can have access to what could easily be changed so a user could add thier login name to the access what ever I am trying...
  18. S

    Controlling access to a form

    Hi there... Im trying to control access to a form I have two ideas and thought Id see if anyone has any suggestions. Ive thought of numerous methods where you can have a deppartment ID and the button ref's that to allow access. Or add user names to the vba code so only those name would be able...
  19. S

    Trying to select from a table then export with VBA

    Ah theres me not thinking straight, all I needed to do was to add criteria to the query which met what I was looking to output - sorry :)
  20. S

    Trying to select from a table then export with VBA

    Hi guys, Im trying to get this code to select from a table based on a field and then export. I know I can do it using a query but would like to further my sql and vba knowledge. Can anyone assist please? The code I have currently is Dim strPasswd strPasswd = InputBox("Enter Password"...
Back
Top Bottom